public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: osd_uld: remove an unneeded NULL check
@ 2017-03-23 10:41 Dan Carpenter
  2017-03-23 19:38 ` Boaz Harrosh
  2017-03-28  1:54 ` Martin K. Petersen
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2017-03-23 10:41 UTC (permalink / raw)
  To: Boaz Harrosh
  Cc: Benny Halevy, James E.J. Bottomley, Martin K. Petersen, osd-dev,
	linux-scsi, linux-kernel, kernel-janitors

We don't call the remove() function unless probe() succeeds so "oud"
can't be NULL here.  Plus, if it were NULL, we dereference it on the
next line so it would crash anyway.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/scsi/osd/osd_uld.c b/drivers/scsi/osd/osd_uld.c
index 4101c3178411..8b9941a5687a 100644
--- a/drivers/scsi/osd/osd_uld.c
+++ b/drivers/scsi/osd/osd_uld.c
@@ -507,10 +507,9 @@ static int osd_remove(struct device *dev)
 	struct scsi_device *scsi_device = to_scsi_device(dev);
 	struct osd_uld_device *oud = dev_get_drvdata(dev);
 
-	if (!oud || (oud->od.scsi_device != scsi_device)) {
-		OSD_ERR("Half cooked osd-device %p,%p || %p!=%p",
-			dev, oud, oud ? oud->od.scsi_device : NULL,
-			scsi_device);
+	if (oud->od.scsi_device != scsi_device) {
+		OSD_ERR("Half cooked osd-device %p, || %p!=%p",
+			dev, oud->od.scsi_device, scsi_device);
 	}
 
 	cdev_device_del(&oud->cdev, &oud->class_dev);

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] scsi: osd_uld: remove an unneeded NULL check
  2017-03-23 10:41 [PATCH] scsi: osd_uld: remove an unneeded NULL check Dan Carpenter
@ 2017-03-23 19:38 ` Boaz Harrosh
  2017-03-28  1:54 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Boaz Harrosh @ 2017-03-23 19:38 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Benny Halevy, James E.J. Bottomley, Martin K. Petersen, osd-dev,
	linux-scsi, linux-kernel, kernel-janitors

On 03/23/2017 12:41 PM, Dan Carpenter wrote:
> We don't call the remove() function unless probe() succeeds so "oud"
> can't be NULL here.  Plus, if it were NULL, we dereference it on the
> next line so it would crash anyway.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 

Thanks sure!
ACK-by Boaz Harrosh <ooo@electrozaur.com>

> diff --git a/drivers/scsi/osd/osd_uld.c b/drivers/scsi/osd/osd_uld.c
> index 4101c3178411..8b9941a5687a 100644
> --- a/drivers/scsi/osd/osd_uld.c
> +++ b/drivers/scsi/osd/osd_uld.c
> @@ -507,10 +507,9 @@ static int osd_remove(struct device *dev)
>  	struct scsi_device *scsi_device = to_scsi_device(dev);
>  	struct osd_uld_device *oud = dev_get_drvdata(dev);
>  
> -	if (!oud || (oud->od.scsi_device != scsi_device)) {
> -		OSD_ERR("Half cooked osd-device %p,%p || %p!=%p",
> -			dev, oud, oud ? oud->od.scsi_device : NULL,
> -			scsi_device);
> +	if (oud->od.scsi_device != scsi_device) {
> +		OSD_ERR("Half cooked osd-device %p, || %p!=%p",
> +			dev, oud->od.scsi_device, scsi_device);
>  	}
>  
>  	cdev_device_del(&oud->cdev, &oud->class_dev);
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] scsi: osd_uld: remove an unneeded NULL check
  2017-03-23 10:41 [PATCH] scsi: osd_uld: remove an unneeded NULL check Dan Carpenter
  2017-03-23 19:38 ` Boaz Harrosh
@ 2017-03-28  1:54 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2017-03-28  1:54 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Boaz Harrosh, Benny Halevy, James E.J. Bottomley,
	Martin K. Petersen, osd-dev, linux-scsi, linux-kernel,
	kernel-janitors

Dan Carpenter <dan.carpenter@oracle.com> writes:

> We don't call the remove() function unless probe() succeeds so "oud"
> can't be NULL here.  Plus, if it were NULL, we dereference it on the
> next line so it would crash anyway.

Applied to 4.12/scsi-queue (by hand).

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-03-28  1:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-23 10:41 [PATCH] scsi: osd_uld: remove an unneeded NULL check Dan Carpenter
2017-03-23 19:38 ` Boaz Harrosh
2017-03-28  1:54 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox