aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-03-27 07:46:26 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-03-27 07:46:26 -0400
commit69197ad70ef6b854988299c1377864f9755cd03d (patch)
treecf467f7a7701b55b18488538ab0a7cf9df50ec27 /drivers
parent304ffd6d3a145901ac570b8afb6c9936a83c3392 (diff)
ide: fix memleak on failure in probe_for_drive()
Always free drive->id in probe_for_drive() if device is not present. While at it: - remove dead IDE_DFLAG_DEAD flag - remove superfluous IDE_DFLAG_PRESENT check Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ide/ide-probe.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index a3edbb5d045..4b00945cf7d 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -228,15 +228,9 @@ static void do_identify(ide_drive_t *drive, u8 cmd, u16 *id)
228 m[ATA_ID_PROD_LEN - 1] = '\0'; 228 m[ATA_ID_PROD_LEN - 1] = '\0';
229 229
230 if (strstr(m, "E X A B Y T E N E S T")) 230 if (strstr(m, "E X A B Y T E N E S T"))
231 goto err_misc; 231 drive->dev_flags &= ~IDE_DFLAG_PRESENT;
232 232 else
233 drive->dev_flags |= IDE_DFLAG_PRESENT; 233 drive->dev_flags |= IDE_DFLAG_PRESENT;
234 drive->dev_flags &= ~IDE_DFLAG_DEAD;
235
236 return;
237err_misc:
238 kfree(id);
239 drive->dev_flags &= ~IDE_DFLAG_PRESENT;
240} 234}
241 235
242/** 236/**
@@ -505,8 +499,7 @@ static u8 probe_for_drive(ide_drive_t *drive)
505 } 499 }
506 500
507 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) 501 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
508 /* drive not found */ 502 goto out_free;
509 return 0;
510 503
511 /* identification failed? */ 504 /* identification failed? */
512 if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) { 505 if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) {
@@ -530,7 +523,7 @@ static u8 probe_for_drive(ide_drive_t *drive)
530 } 523 }
531 524
532 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) 525 if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
533 return 0; 526 goto out_free;
534 527
535 /* The drive wasn't being helpful. Add generic info only */ 528 /* The drive wasn't being helpful. Add generic info only */
536 if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) { 529 if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) {
@@ -543,7 +536,10 @@ static u8 probe_for_drive(ide_drive_t *drive)
543 ide_disk_init_mult_count(drive); 536 ide_disk_init_mult_count(drive);
544 } 537 }
545 538
546 return !!(drive->dev_flags & IDE_DFLAG_PRESENT); 539 return 1;
540out_free:
541 kfree(drive->id);
542 return 0;
547} 543}
548 544
549static void hwif_release_dev(struct device *dev) 545static void hwif_release_dev(struct device *dev)