Skip to content

Commit e73c864

Browse files
Colin Ian Kingmartinkpetersen
authored andcommitted
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 <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 10ee1f2 commit e73c864

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/scsi/aic7xxx/aic79xx_core.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6112,17 +6112,17 @@ ahd_alloc(void *platform_arg, char *name)
61126112
ahd->int_coalescing_stop_threshold =
61136113
AHD_INT_COALESCING_STOP_THRESHOLD_DEFAULT;
61146114

6115-
if (ahd_platform_alloc(ahd, platform_arg) != 0) {
6116-
ahd_free(ahd);
6117-
ahd = NULL;
6118-
}
61196115
#ifdef AHD_DEBUG
61206116
if ((ahd_debug & AHD_SHOW_MEMORY) != 0) {
61216117
printk("%s: scb size = 0x%x, hscb size = 0x%x\n",
61226118
ahd_name(ahd), (u_int)sizeof(struct scb),
61236119
(u_int)sizeof(struct hardware_scb));
61246120
}
61256121
#endif
6122+
if (ahd_platform_alloc(ahd, platform_arg) != 0) {
6123+
ahd_free(ahd);
6124+
ahd = NULL;
6125+
}
61266126
return (ahd);
61276127
}
61286128

0 commit comments

Comments
 (0)