Skip to content

Commit 288315e

Browse files
gkennedy12martinkpetersen
authored andcommitted
scsi: sym53c8xx: fix NULL pointer dereference panic in sym_int_sir()
sym_int_sir() in sym_hipd.c does not check the command pointer for NULL before using it in debug message prints. Suggested-by: Matthew Wilcox <matthew.wilcox@oracle.com> Signed-off-by: George Kennedy <george.kennedy@oracle.com> Reviewed-by: Mark Kanda <mark.kanda@oracle.com> Acked-by: Matthew Wilcox <matthew.wilcox@oracle.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 6318cb7 commit 288315e

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

‎drivers/scsi/sym53c8xx_2/sym_hipd.c‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4370,6 +4370,13 @@ static void sym_nego_rejected(struct sym_hcb *np, struct sym_tcb *tp, struct sym
43704370
OUTB(np, HS_PRT, HS_BUSY);
43714371
}
43724372

4373+
#define sym_printk(lvl, tp, cp, fmt, v...) do { \
4374+
if (cp) \
4375+
scmd_printk(lvl, cp->cmd, fmt, ##v); \
4376+
else \
4377+
starget_printk(lvl, tp->starget, fmt, ##v); \
4378+
} while (0)
4379+
43734380
/*
43744381
* chip exception handler for programmed interrupts.
43754382
*/
@@ -4415,23 +4422,23 @@ static void sym_int_sir(struct sym_hcb *np)
44154422
* been selected with ATN. We do not want to handle that.
44164423
*/
44174424
case SIR_SEL_ATN_NO_MSG_OUT:
4418-
scmd_printk(KERN_WARNING, cp->cmd,
4425+
sym_printk(KERN_WARNING, tp, cp,
44194426
"No MSG OUT phase after selection with ATN\n");
44204427
goto out_stuck;
44214428
/*
44224429
* The device didn't switch to MSG IN phase after
44234430
* having reselected the initiator.
44244431
*/
44254432
case SIR_RESEL_NO_MSG_IN:
4426-
scmd_printk(KERN_WARNING, cp->cmd,
4433+
sym_printk(KERN_WARNING, tp, cp,
44274434
"No MSG IN phase after reselection\n");
44284435
goto out_stuck;
44294436
/*
44304437
* After reselection, the device sent a message that wasn't
44314438
* an IDENTIFY.
44324439
*/
44334440
case SIR_RESEL_NO_IDENTIFY:
4434-
scmd_printk(KERN_WARNING, cp->cmd,
4441+
sym_printk(KERN_WARNING, tp, cp,
44354442
"No IDENTIFY after reselection\n");
44364443
goto out_stuck;
44374444
/*
@@ -4460,7 +4467,7 @@ static void sym_int_sir(struct sym_hcb *np)
44604467
case SIR_RESEL_ABORTED:
44614468
np->lastmsg = np->msgout[0];
44624469
np->msgout[0] = M_NOOP;
4463-
scmd_printk(KERN_WARNING, cp->cmd,
4470+
sym_printk(KERN_WARNING, tp, cp,
44644471
"message %x sent on bad reselection\n", np->lastmsg);
44654472
goto out;
44664473
/*

0 commit comments

Comments
 (0)