Skip to content

Commit a656d47

Browse files
author
Al Viro
committed
scsi_ioctl.c: switch SCSI_IOCTL_GET_IDLUN to copy_to_user()
Signed-off-by: Al Viro <[email protected]>
1 parent ce5155c commit a656d47

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

drivers/scsi/scsi_ioctl.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -211,18 +211,18 @@ static int scsi_ioctl_common(struct scsi_device *sdev, int cmd, void __user *arg
211211
}
212212

213213
switch (cmd) {
214-
case SCSI_IOCTL_GET_IDLUN:
215-
if (!access_ok(arg, sizeof(struct scsi_idlun)))
214+
case SCSI_IOCTL_GET_IDLUN: {
215+
struct scsi_idlun v = {
216+
.dev_id = (sdev->id & 0xff)
217+
+ ((sdev->lun & 0xff) << 8)
218+
+ ((sdev->channel & 0xff) << 16)
219+
+ ((sdev->host->host_no & 0xff) << 24),
220+
.host_unique_id = sdev->host->unique_id
221+
};
222+
if (copy_to_user(arg, &v, sizeof(struct scsi_idlun)))
216223
return -EFAULT;
217-
218-
__put_user((sdev->id & 0xff)
219-
+ ((sdev->lun & 0xff) << 8)
220-
+ ((sdev->channel & 0xff) << 16)
221-
+ ((sdev->host->host_no & 0xff) << 24),
222-
&((struct scsi_idlun __user *)arg)->dev_id);
223-
__put_user(sdev->host->unique_id,
224-
&((struct scsi_idlun __user *)arg)->host_unique_id);
225224
return 0;
225+
}
226226
case SCSI_IOCTL_GET_BUS_NUMBER:
227227
return put_user(sdev->host->host_no, (int __user *)arg);
228228
case SCSI_IOCTL_PROBE_HOST:

0 commit comments

Comments
 (0)