Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: hpsa: Use vmemdup_user to replace the open code

vmemdup_user is better than duplicating its implementation, So just replace
the open code.

The issue is detected with the help of Coccinelle.

Tested-by: Don Brace <don.brace@microsemi.com>
Acked-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: zhong jiang <zhongjiang@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

zhong jiang and committed by
Martin K. Petersen
048a864e 874deb1c

+4 -8
+4 -8
drivers/scsi/hpsa.c
··· 6381 6381 return -EINVAL; 6382 6382 if (!capable(CAP_SYS_RAWIO)) 6383 6383 return -EPERM; 6384 - ioc = kmalloc(sizeof(*ioc), GFP_KERNEL); 6385 - if (!ioc) { 6386 - status = -ENOMEM; 6387 - goto cleanup1; 6388 - } 6389 - if (copy_from_user(ioc, argp, sizeof(*ioc))) { 6390 - status = -EFAULT; 6384 + ioc = vmemdup_user(argp, sizeof(*ioc)); 6385 + if (IS_ERR(ioc)) { 6386 + status = PTR_ERR(ioc); 6391 6387 goto cleanup1; 6392 6388 } 6393 6389 if ((ioc->buf_size < 1) && ··· 6501 6505 kfree(buff); 6502 6506 } 6503 6507 kfree(buff_size); 6504 - kfree(ioc); 6508 + kvfree(ioc); 6505 6509 return status; 6506 6510 } 6507 6511