* [PATCH] scsi: aic7xxx: aic79xx: fix potential null pointer dereference on ahd
@ 2018-05-31 12:31 Colin King
2018-06-06 1:38 ` Martin K. Petersen
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2018-05-31 12:31 UTC (permalink / raw)
To: Hannes Reinecke, James E . J . Bottomley, Martin K . Petersen,
linux-scsi
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
If AHD_DEBUG is enabled and ahd_platform_alloc fails then ahd is set
to null and the debug printk dereferences ahd when passing it to
ahd_name. Fix this by moving the debug printk to before the call
to ahd_platform_alloc where ahd is not null at that point.
Detected by CoverityScan, CID#100296 ("Explicit null dereference")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/scsi/aic7xxx/aic79xx_core.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/scsi/aic7xxx/aic79xx_core.c b/drivers/scsi/aic7xxx/aic79xx_core.c
index 034f4eebb160..3efd4cdc40a0 100644
--- a/drivers/scsi/aic7xxx/aic79xx_core.c
+++ b/drivers/scsi/aic7xxx/aic79xx_core.c
@@ -6112,10 +6112,6 @@ ahd_alloc(void *platform_arg, char *name)
ahd->int_coalescing_stop_threshold AHD_INT_COALESCING_STOP_THRESHOLD_DEFAULT;
- if (ahd_platform_alloc(ahd, platform_arg) != 0) {
- ahd_free(ahd);
- ahd = NULL;
- }
#ifdef AHD_DEBUG
if ((ahd_debug & AHD_SHOW_MEMORY) != 0) {
printk("%s: scb size = 0x%x, hscb size = 0x%x\n",
@@ -6123,6 +6119,10 @@ ahd_alloc(void *platform_arg, char *name)
(u_int)sizeof(struct hardware_scb));
}
#endif
+ if (ahd_platform_alloc(ahd, platform_arg) != 0) {
+ ahd_free(ahd);
+ ahd = NULL;
+ }
return (ahd);
}
--
2.17.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] scsi: aic7xxx: aic79xx: fix potential null pointer dereference on ahd
2018-05-31 12:31 [PATCH] scsi: aic7xxx: aic79xx: fix potential null pointer dereference on ahd Colin King
@ 2018-06-06 1:38 ` Martin K. Petersen
0 siblings, 0 replies; 2+ messages in thread
From: Martin K. Petersen @ 2018-06-06 1:38 UTC (permalink / raw)
To: Colin King
Cc: Hannes Reinecke, James E . J . Bottomley, Martin K . Petersen,
linux-scsi, kernel-janitors, linux-kernel
Colin,
> If AHD_DEBUG is enabled and ahd_platform_alloc fails then ahd is set
> to null and the debug printk dereferences ahd when passing it to
> ahd_name. Fix this by moving the debug printk to before the call to
> ahd_platform_alloc where ahd is not null at that point.
Applied to 4.18/scsi-fixes. Thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-06-06 1:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-31 12:31 [PATCH] scsi: aic7xxx: aic79xx: fix potential null pointer dereference on ahd Colin King
2018-06-06 1:38 ` 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;
as well as URLs for NNTP newsgroup(s).