[PATCH scsi] Add NULL checking of return value from scsi_cmd_to_driver()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Just noticed that after commit 919f797, it is possible that 
scsi_cmd_to_driver() returns NULL. This patch adds the NULL checking for drv 
returned from the above function. 

Maybe it is not possible at run time, but from the code itself, we'd better
have this check?  

This patch actually is a delta of my previous patch 
[https://lkml.org/lkml/2012/4/11/814] and commit 919f797

Signed-off-by: Li Zhong <zhong@xxxxxxxxxxxxxxxxxx>
---

diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 2936b44..b9dd7f0 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -832,7 +832,7 @@ void scsi_finish_command(struct scsi_cmnd *cmd)
         if (cmd->request->cmd_type != REQ_TYPE_BLOCK_PC) {
 		int old_good_bytes = good_bytes;
 		drv = scsi_cmd_to_driver(cmd);
-		if (drv->done)
+		if (drv && drv->done)
 			good_bytes = drv->done(cmd);
 		/*
 		 * USB may not give sense identifying bad sector and


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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux