mirror of
https://github.com/torvalds/linux.git
synced 2026-05-28 09:04:39 +02:00
scsi: scsi_debug: Replace kzalloc() + copy_from_user() with memdup_user_nul()
Replace kzalloc() followed by copy_from_user() with memdup_user_nul() to improve and simplify sdebug_error_write(). No functional changes intended. Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
5cffc679ad
commit
8791b07894
|
|
@ -1155,14 +1155,9 @@ static ssize_t sdebug_error_write(struct file *file, const char __user *ubuf,
|
|||
struct sdebug_err_inject *inject;
|
||||
struct scsi_device *sdev = (struct scsi_device *)file->f_inode->i_private;
|
||||
|
||||
buf = kzalloc(count + 1, GFP_KERNEL);
|
||||
if (!buf)
|
||||
return -ENOMEM;
|
||||
|
||||
if (copy_from_user(buf, ubuf, count)) {
|
||||
kfree(buf);
|
||||
return -EFAULT;
|
||||
}
|
||||
buf = memdup_user_nul(ubuf, count);
|
||||
if (IS_ERR(buf))
|
||||
return PTR_ERR(buf);
|
||||
|
||||
if (buf[0] == '-')
|
||||
return sdebug_err_remove(sdev, buf, count);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user