diff options
Diffstat (limited to 'drivers/mtd/mtdchar.c')
-rw-r--r-- | drivers/mtd/mtdchar.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index 2147e733533b..250798cf76aa 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c | |||
@@ -889,25 +889,26 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg) | |||
889 | case OTPGETREGIONINFO: | 889 | case OTPGETREGIONINFO: |
890 | { | 890 | { |
891 | struct otp_info *buf = kmalloc(4096, GFP_KERNEL); | 891 | struct otp_info *buf = kmalloc(4096, GFP_KERNEL); |
892 | size_t retlen; | ||
892 | if (!buf) | 893 | if (!buf) |
893 | return -ENOMEM; | 894 | return -ENOMEM; |
894 | switch (mfi->mode) { | 895 | switch (mfi->mode) { |
895 | case MTD_FILE_MODE_OTP_FACTORY: | 896 | case MTD_FILE_MODE_OTP_FACTORY: |
896 | ret = mtd_get_fact_prot_info(mtd, buf, 4096); | 897 | ret = mtd_get_fact_prot_info(mtd, 4096, &retlen, buf); |
897 | break; | 898 | break; |
898 | case MTD_FILE_MODE_OTP_USER: | 899 | case MTD_FILE_MODE_OTP_USER: |
899 | ret = mtd_get_user_prot_info(mtd, buf, 4096); | 900 | ret = mtd_get_user_prot_info(mtd, 4096, &retlen, buf); |
900 | break; | 901 | break; |
901 | default: | 902 | default: |
902 | ret = -EINVAL; | 903 | ret = -EINVAL; |
903 | break; | 904 | break; |
904 | } | 905 | } |
905 | if (ret >= 0) { | 906 | if (!ret) { |
906 | if (cmd == OTPGETREGIONCOUNT) { | 907 | if (cmd == OTPGETREGIONCOUNT) { |
907 | int nbr = ret / sizeof(struct otp_info); | 908 | int nbr = retlen / sizeof(struct otp_info); |
908 | ret = copy_to_user(argp, &nbr, sizeof(int)); | 909 | ret = copy_to_user(argp, &nbr, sizeof(int)); |
909 | } else | 910 | } else |
910 | ret = copy_to_user(argp, buf, ret); | 911 | ret = copy_to_user(argp, buf, retlen); |
911 | if (ret) | 912 | if (ret) |
912 | ret = -EFAULT; | 913 | ret = -EFAULT; |
913 | } | 914 | } |