libata: add missing NULL pointer check to ata_eh_reset()
PATCH 1/1 libata: add missing NULL pointer check to ata_eh_reset()
From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] libata: add missing NULL pointer check to ata_eh_reset()
Quoted 1 line
From Dan's list:
drivers/ata/libata-eh.c +2403 ata_eh_reset(80) warning: variable derefenced before check 'slave'
Please note that this is _not_ a real bug at the moment since ata_eh_context structure is embedded into ata_list structure and the code alwas checks for 'slave' before accessing 'sehc'.
Anyway lets add missing check and always have a valid 'sehc' pointer (which makes code easier to understand and prevents introducing some possible bugs in the future).
--- drivers/ata/libata-eh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/libata-eh.c +1 -1
@@ -2329,7 +2329,7 @@ int ata_eh_reset(struct ata_link *link,struct ata_port *ap = link->ap;struct ata_link *slave = ap->slave_link;struct ata_eh_context *ehc = &link->eh_context; -struct ata_eh_context *sehc = &slave->eh_context; +struct ata_eh_context *sehc = slave ? &slave->eh_context :NULL ;unsigned int *classes = ehc->classes;unsigned int lflags = link->flags;int verbose = !(ehc->i.flags &ATA_EHI_QUIET );
Jeff Garzik
AppliedQuoted 15 lines · Bartlomiej Zolnierkiewicz
From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] libata: add missing NULL pointer check toata_eh_reset()Quoted 1 line
From Dan's list:
drivers/ata/libata-eh.c+2403ata_eh_reset(80)warning: variable derefenced before check 'slave'Please note that this is _not_ a real bug at the moment since
ata_eh_contextstructure is embedded intoata_liststructure and the code alwas checks for 'slave' before accessing 'sehc'.Anyway lets add missing check and always have a valid 'sehc' pointer (which makes code easier to understand and prevents introducing some possible bugs in the future).
Quoted 7 lines
Reported-by Dan Carpenter <[email protected]>Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>--- drivers/ata/libata-eh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
applied to #upstream-fixes