[PATCH][sas] Fix potential NULL pointer dereference bug in sas_smp_handler()

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-scsi@...>
Cc: Luben Tuikov <luben_tuikov@...>, James Bottomley <James.Bottomley@...>, Linux Kernel Mailing List <linux-kernel@...>, Jesper Juhl <jesper.juhl@...>
Date: Friday, July 27, 2007 - 3:58 pm

Hi,

The Coverity checker found a problem in 
drivers/scsi/libsas/sas_expander.c::sas_smp_handler().
We dereference a pointer before testing if it is NULL. Easily fixed 
in this case by simply moving an assignment down a bit.

Please consider for inclusion.

Patch has been compile tested only.


Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---

 drivers/scsi/libsas/sas_expander.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index b500f0c..7871406 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -1879,7 +1879,7 @@ int sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
 		    struct request *req)
 {
 	struct domain_device *dev;
-	int ret, type = rphy->identify.device_type;
+	int ret, type;
 	struct request *rsp = req->next_rq;
 
 	if (!rsp) {
@@ -1895,6 +1895,8 @@ int sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
 		return -EINVAL;
 	}
 
+	type = rphy->identify.device_type;
+
 	if (type != SAS_EDGE_EXPANDER_DEVICE &&
 	    type != SAS_FANOUT_EXPANDER_DEVICE) {
 		printk("%s: can we send a smp request to a device?\n",





  PS. Please keep me on Cc when replying.


-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH][sas] Fix potential NULL pointer dereference bug in s..., Jesper Juhl, (Fri Jul 27, 3:58 pm)