Re: [PATCH v6 1/4] sg: use rwsem to solve race during exclusive open

From: James Bottomley
Date: Wed Aug 28 2013 - 06:26:27 EST


On Wed, 2013-08-28 at 18:07 +0800, Vaughan Cao wrote:
> @@ -331,17 +330,20 @@ sg_open(struct inode *inode, struct file *filp)
> }
> if ((sfp = sg_add_sfp(sdp, dev)))
> filp->private_data = sfp;
> - else {
> + /* retval is already provably zero at this point
> because of the
> + * check after retval =
> scsi_autopm_get_device(sdp->device))
> + */
> + else
> + retval = -ENOMEM;
> +
> + if (retval) {
> +sem_out:

There's still no need for the double if. You know the value of retval
in each of the legs of the first if; its only non zero for the else leg,
so you can combine them thus:

if ((sfp = sg_add_sfp(sdp, dev)))
filp->private_data = sfp;
/* retval is already provably zero at this point because of the
* check after retval scsi_autopm_get_device(sdp->device))
*/
else {
retval = -ENOMEM;
sem_out:
...

James



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/