diff options
author | Colin Ian King <colin.king@canonical.com> | 2018-05-31 08:31:17 -0400 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2018-06-07 21:50:00 -0400 |
commit | e73c864ba3b57cc3c5cc6b328b9da1b48637a6df (patch) | |
tree | 24c0b66ca701328c70fee6435065e152b34a9cdf | |
parent | 10ee1f2206a3f5aa869bede4b7505b24203a7715 (diff) |
scsi: aic7xxx: aic79xx: fix potential null pointer dereference on ahd
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>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r-- | drivers/scsi/aic7xxx/aic79xx_core.c | 8 |
1 files 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) | |||
6112 | ahd->int_coalescing_stop_threshold = | 6112 | ahd->int_coalescing_stop_threshold = |
6113 | AHD_INT_COALESCING_STOP_THRESHOLD_DEFAULT; | 6113 | AHD_INT_COALESCING_STOP_THRESHOLD_DEFAULT; |
6114 | 6114 | ||
6115 | if (ahd_platform_alloc(ahd, platform_arg) != 0) { | ||
6116 | ahd_free(ahd); | ||
6117 | ahd = NULL; | ||
6118 | } | ||
6119 | #ifdef AHD_DEBUG | 6115 | #ifdef AHD_DEBUG |
6120 | if ((ahd_debug & AHD_SHOW_MEMORY) != 0) { | 6116 | if ((ahd_debug & AHD_SHOW_MEMORY) != 0) { |
6121 | printk("%s: scb size = 0x%x, hscb size = 0x%x\n", | 6117 | printk("%s: scb size = 0x%x, hscb size = 0x%x\n", |
@@ -6123,6 +6119,10 @@ ahd_alloc(void *platform_arg, char *name) | |||
6123 | (u_int)sizeof(struct hardware_scb)); | 6119 | (u_int)sizeof(struct hardware_scb)); |
6124 | } | 6120 | } |
6125 | #endif | 6121 | #endif |
6122 | if (ahd_platform_alloc(ahd, platform_arg) != 0) { | ||
6123 | ahd_free(ahd); | ||
6124 | ahd = NULL; | ||
6125 | } | ||
6126 | return (ahd); | 6126 | return (ahd); |
6127 | } | 6127 | } |
6128 | 6128 | ||