Skip to content

Commit

Permalink
scsi_ioctl.c: switch SCSI_IOCTL_GET_IDLUN to copy_to_user()
Browse files Browse the repository at this point in the history
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Apr 25, 2020
1 parent ce5155c commit a656d47
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions drivers/scsi/scsi_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,18 +211,18 @@ static int scsi_ioctl_common(struct scsi_device *sdev, int cmd, void __user *arg
}

switch (cmd) {
case SCSI_IOCTL_GET_IDLUN:
if (!access_ok(arg, sizeof(struct scsi_idlun)))
case SCSI_IOCTL_GET_IDLUN: {
struct scsi_idlun v = {
.dev_id = (sdev->id & 0xff)
+ ((sdev->lun & 0xff) << 8)
+ ((sdev->channel & 0xff) << 16)
+ ((sdev->host->host_no & 0xff) << 24),
.host_unique_id = sdev->host->unique_id
};
if (copy_to_user(arg, &v, sizeof(struct scsi_idlun)))
return -EFAULT;

__put_user((sdev->id & 0xff)
+ ((sdev->lun & 0xff) << 8)
+ ((sdev->channel & 0xff) << 16)
+ ((sdev->host->host_no & 0xff) << 24),
&((struct scsi_idlun __user *)arg)->dev_id);
__put_user(sdev->host->unique_id,
&((struct scsi_idlun __user *)arg)->host_unique_id);
return 0;
}
case SCSI_IOCTL_GET_BUS_NUMBER:
return put_user(sdev->host->host_no, (int __user *)arg);
case SCSI_IOCTL_PROBE_HOST:
Expand Down

0 comments on commit a656d47

Please sign in to comment.