* [PATCH] libata: add missing NULL pointer check to ata_eh_reset()
@ 2009-07-26 14:21 Bartlomiej Zolnierkiewicz
2009-07-29 1:10 ` Jeff Garzik
0 siblings, 1 reply; 2+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-07-26 14:21 UTC (permalink / raw)
To: jgarzik; +Cc: linux-kernel, linux-ide, Dan Carpenter, corbet, eteo
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] libata: add missing NULL pointer check to ata_eh_reset()
>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).
Reported-by: Dan Carpenter <error27@gmail.com>
Cc: corbet@lwn.net
Cc: eteo@redhat.com
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
drivers/ata/libata-eh.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: b/drivers/ata/libata-eh.c
===================================================================
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -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);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] libata: add missing NULL pointer check to ata_eh_reset()
2009-07-26 14:21 [PATCH] libata: add missing NULL pointer check to ata_eh_reset() Bartlomiej Zolnierkiewicz
@ 2009-07-29 1:10 ` Jeff Garzik
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Garzik @ 2009-07-29 1:10 UTC (permalink / raw)
To: Bartlomiej Zolnierkiewicz
Cc: linux-kernel, linux-ide, Dan Carpenter, corbet, eteo
Bartlomiej Zolnierkiewicz wrote:
> From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
> Subject: [PATCH] libata: add missing NULL pointer check to ata_eh_reset()
>
>>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).
>
> Reported-by: Dan Carpenter <error27@gmail.com>
> Cc: corbet@lwn.net
> Cc: eteo@redhat.com
> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
> ---
> drivers/ata/libata-eh.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
applied to #upstream-fixes
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-07-29 1:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-26 14:21 [PATCH] libata: add missing NULL pointer check to ata_eh_reset() Bartlomiej Zolnierkiewicz
2009-07-29 1:10 ` Jeff Garzik
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).