mtd: Add a retlen parameter to _get_{fact,user}_prot_info
Signed-off-by: Christian Riesch <christian.riesch@omicron.at> Cc: Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
This commit is contained in:

committed by
Brian Norris

parent
41bf1a24c1
commit
4b78fc42f3
@@ -889,25 +889,26 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg)
|
||||
case OTPGETREGIONINFO:
|
||||
{
|
||||
struct otp_info *buf = kmalloc(4096, GFP_KERNEL);
|
||||
size_t retlen;
|
||||
if (!buf)
|
||||
return -ENOMEM;
|
||||
switch (mfi->mode) {
|
||||
case MTD_FILE_MODE_OTP_FACTORY:
|
||||
ret = mtd_get_fact_prot_info(mtd, buf, 4096);
|
||||
ret = mtd_get_fact_prot_info(mtd, 4096, &retlen, buf);
|
||||
break;
|
||||
case MTD_FILE_MODE_OTP_USER:
|
||||
ret = mtd_get_user_prot_info(mtd, buf, 4096);
|
||||
ret = mtd_get_user_prot_info(mtd, 4096, &retlen, buf);
|
||||
break;
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
if (ret >= 0) {
|
||||
if (!ret) {
|
||||
if (cmd == OTPGETREGIONCOUNT) {
|
||||
int nbr = ret / sizeof(struct otp_info);
|
||||
int nbr = retlen / sizeof(struct otp_info);
|
||||
ret = copy_to_user(argp, &nbr, sizeof(int));
|
||||
} else
|
||||
ret = copy_to_user(argp, buf, ret);
|
||||
ret = copy_to_user(argp, buf, retlen);
|
||||
if (ret)
|
||||
ret = -EFAULT;
|
||||
}
|
||||
|
Reference in New Issue
Block a user