All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Wetzel <alexander@wetzel-home.de>
To: Bart Van Assche <bvanassche@acm.org>, dgilbert@interlog.com
Cc: gregkh@linuxfoundation.org, sachinp@linux.ibm.com,
	linux-scsi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	martin.petersen@oracle.com, stable@vger.kernel.org
Subject: Re: [PATCH v3] scsi: sg: Avoid race in error handling & drop bogus warn
Date: Thu, 4 Apr 2024 08:55:30 +0200	[thread overview]
Message-ID: <5cbb1668-1640-4a5d-b6a8-ed0e5840b9ee@wetzel-home.de> (raw)
In-Reply-To: <bc800bdd-6563-40ba-bc8d-e98b87748c15@acm.org>

On 04.04.24 01:24, Bart Van Assche wrote:
> On 4/1/24 12:10 PM, Alexander Wetzel wrote:
>> @@ -301,11 +302,12 @@ sg_open(struct inode *inode, struct file *filp)
>>       /* This driver's module count bumped by fops_get in <linux/fs.h> */
>>       /* Prevent the device driver from vanishing while we sleep */
>> -    retval = scsi_device_get(sdp->device);
>> +    device = sdp->device;
>> +    retval = scsi_device_get(device);
>>       if (retval)
>>           goto sg_put;
> 
> Are all the sdp->device -> device changes essential? Isn't there a
> preference to minimize patches that will end up in the stable trees?
> 

Only the very last change is essential:
-       scsi_device_put(sdp->device);
-       goto sg_put;
+       kref_put(&sdp->d_ref, sg_device_destroy);
+       scsi_device_put(device);
+       return retval;

Not using a (required) local variable and de-referencing it again and 
looks strange for anyone reading the code. While the additional lines in 
the patch are trivial to review...

Alexander

WARNING: multiple messages have this Message-ID (diff)
From: Alexander Wetzel <alexander@wetzel-home.de>
To: Bart Van Assche <bvanassche@acm.org>, dgilbert@interlog.com
Cc: martin.petersen@oracle.com, linux-scsi@vger.kernel.org,
	gregkh@linuxfoundation.org, stable@vger.kernel.org,
	sachinp@linux.ibm.com, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v3] scsi: sg: Avoid race in error handling & drop bogus warn
Date: Thu, 4 Apr 2024 08:55:30 +0200	[thread overview]
Message-ID: <5cbb1668-1640-4a5d-b6a8-ed0e5840b9ee@wetzel-home.de> (raw)
In-Reply-To: <bc800bdd-6563-40ba-bc8d-e98b87748c15@acm.org>

On 04.04.24 01:24, Bart Van Assche wrote:
> On 4/1/24 12:10 PM, Alexander Wetzel wrote:
>> @@ -301,11 +302,12 @@ sg_open(struct inode *inode, struct file *filp)
>>       /* This driver's module count bumped by fops_get in <linux/fs.h> */
>>       /* Prevent the device driver from vanishing while we sleep */
>> -    retval = scsi_device_get(sdp->device);
>> +    device = sdp->device;
>> +    retval = scsi_device_get(device);
>>       if (retval)
>>           goto sg_put;
> 
> Are all the sdp->device -> device changes essential? Isn't there a
> preference to minimize patches that will end up in the stable trees?
> 

Only the very last change is essential:
-       scsi_device_put(sdp->device);
-       goto sg_put;
+       kref_put(&sdp->d_ref, sg_device_destroy);
+       scsi_device_put(device);
+       return retval;

Not using a (required) local variable and de-referencing it again and 
looks strange for anyone reading the code. While the additional lines in 
the patch are trivial to review...

Alexander

  reply	other threads:[~2024-04-04  6:55 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-29  9:08 [powerpc] WARN at drivers/scsi/sg.c:2236 (sg_remove_sfp_usercontext) Sachin Sant
2024-03-29  9:08 ` Sachin Sant
2024-03-29 11:10 ` Alexander Wetzel
2024-03-29 11:10   ` Alexander Wetzel
2024-03-29 14:37   ` Sachin Sant
2024-04-01  9:56     ` [PATCH] scsi: sg: Avoid race in error handling & drop bogus warn Alexander Wetzel
2024-04-01  9:56       ` Alexander Wetzel
2024-04-01 10:03     ` [PATCH v2] " Alexander Wetzel
2024-04-01 10:03       ` Alexander Wetzel
2024-04-01 17:09       ` Bart Van Assche
2024-04-01 17:09         ` Bart Van Assche
2024-04-01 19:01         ` Alexander Wetzel
2024-04-01 19:01           ` Alexander Wetzel
2024-04-01 19:10     ` [PATCH v3] " Alexander Wetzel
2024-04-01 19:10       ` Alexander Wetzel
2024-04-02  6:01       ` Sachin Sant
2024-04-02  6:01         ` Sachin Sant
2024-04-03 23:24       ` Bart Van Assche
2024-04-03 23:24         ` Bart Van Assche
2024-04-04  6:55         ` Alexander Wetzel [this message]
2024-04-04  6:55           ` Alexander Wetzel
2024-04-04 16:34       ` Bart Van Assche
2024-04-04 16:34         ` Bart Van Assche
2024-04-04 22:22       ` Martin K. Petersen
2024-04-04 22:22         ` Martin K. Petersen
2024-04-06  1:58       ` Martin K. Petersen
2024-04-06  1:58         ` Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5cbb1668-1640-4a5d-b6a8-ed0e5840b9ee@wetzel-home.de \
    --to=alexander@wetzel-home.de \
    --cc=bvanassche@acm.org \
    --cc=dgilbert@interlog.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=martin.petersen@oracle.com \
    --cc=sachinp@linux.ibm.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.