diff mbox series

scsi: esas2r: prevent a potential NULL dereference in esas2r_probe()

Message ID 20200909084653.79341-1-jingxiangfeng@huawei.com
State New
Headers show
Series scsi: esas2r: prevent a potential NULL dereference in esas2r_probe() | expand

Commit Message

Jing Xiangfeng Sept. 9, 2020, 8:46 a.m. UTC
esas2r_probe() calls scsi_host_put() in an error path. However,
esas2r_log_dev() may hit a potential NULL dereference. So use NUll instead.

Signed-off-by: Jing Xiangfeng <jingxiangfeng@huawei.com>
---
 drivers/scsi/esas2r/esas2r_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Martin K. Petersen Sept. 15, 2020, 9:44 p.m. UTC | #1
Jing,

> esas2r_probe() calls scsi_host_put() in an error path. However,
> esas2r_log_dev() may hit a potential NULL dereference. So use NUll instead.

Wouldn't it be better to move the scsi_host_put() call after the error
message?
Jing Xiangfeng Sept. 16, 2020, 12:13 p.m. UTC | #2
On 2020/9/16 5:44, Martin K. Petersen wrote:
>
> Jing,
>
>> esas2r_probe() calls scsi_host_put() in an error path. However,
>> esas2r_log_dev() may hit a potential NULL dereference. So use NUll instead.
>
> Wouldn't it be better to move the scsi_host_put() call after the error
> message?

There is already a message before the scsi_host_put() call. It is used 
to record calling function.

>
Jing Xiangfeng Sept. 16, 2020, 12:28 p.m. UTC | #3
On 2020/9/16 5:44, Martin K. Petersen wrote:
>
> Jing,
>
>> esas2r_probe() calls scsi_host_put() in an error path. However,
>> esas2r_log_dev() may hit a potential NULL dereference. So use NUll instead.
>
> Wouldn't it be better to move the scsi_host_put() call after the error
> message?

There is already a message before the scsi_host_put() call. It is used 
to record calling function.

>
diff mbox series

Patch

diff --git a/drivers/scsi/esas2r/esas2r_main.c b/drivers/scsi/esas2r/esas2r_main.c
index 7b49e2e9fcde..7d3fa9dac4ce 100644
--- a/drivers/scsi/esas2r/esas2r_main.c
+++ b/drivers/scsi/esas2r/esas2r_main.c
@@ -456,7 +456,7 @@  static int esas2r_probe(struct pci_dev *pcid,
 
 		scsi_host_put(host);
 
-		esas2r_log_dev(ESAS2R_LOG_INFO, &(host->shost_gendev),
+		esas2r_log_dev(ESAS2R_LOG_INFO, NULL,
 			       "pci_set_drvdata(%p, NULL) called",
 			       pcid);