lkml.org 
[lkml]   [2019]   [Dec]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2 18/27] compat_ioctl: scsi: move ioctl handling into drivers
From
Date
On Tue, 2019-12-17 at 23:16 +0100, Arnd Bergmann wrote:
[...]
> --- a/drivers/scsi/sr.c
> +++ b/drivers/scsi/sr.c
[...]
> @@ -598,6 +599,55 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
> return ret;
> }
>
> +#ifdef CONFIG_COMPAT
> +static int sr_block_compat_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
> + unsigned long arg)
> +{
> + struct scsi_cd *cd = scsi_cd(bdev->bd_disk);
> + struct scsi_device *sdev = cd->device;
> + void __user *argp = compat_ptr(arg);
> + int ret;
> +
> + mutex_lock(&sr_mutex);
> +
> + ret = scsi_ioctl_block_when_processing_errors(sdev, cmd,
> + (mode & FMODE_NDELAY) != 0);
> + if (ret)
> + goto out;
> +
> + scsi_autopm_get_device(sdev);
> +
> + /*
> + * Send SCSI addressing ioctls directly to mid level, send other
> + * ioctls to cdrom/block level.
> + */
> + switch (cmd) {
> + case SCSI_IOCTL_GET_IDLUN:
> + case SCSI_IOCTL_GET_BUS_NUMBER:
> + ret = scsi_compat_ioctl(sdev, cmd, argp);
> + goto put;
> + }
> +
> + /*
> + * CDROM ioctls are handled in the block layer, but
> + * do the scsi blk ioctls here.
> + */
> + ret = scsi_cmd_blk_ioctl(bdev, mode, cmd, argp);
> + if (ret != -ENOTTY)
> + return ret;

This needs to be be "goto put;"

> + ret = scsi_compat_ioctl(sdev, cmd, argp);
> +
> +put:
> + scsi_autopm_put_device(sdev);
> +
> +out:
> + mutex_unlock(&sr_mutex);
> + return ret;
> +
> +}
> +#endif
[...]

--
Ben Hutchings, Software Developer Codethink Ltd
https://www.codethink.co.uk/ Dale House, 35 Dale Street
Manchester, M1 2HF, United Kingdom

\
 
 \ /
  Last update: 2019-12-18 20:57    [W:1.846 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site