diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-03-27 07:46:26 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-03-27 07:46:26 -0400 |
commit | 69197ad70ef6b854988299c1377864f9755cd03d (patch) | |
tree | cf467f7a7701b55b18488538ab0a7cf9df50ec27 | |
parent | 304ffd6d3a145901ac570b8afb6c9936a83c3392 (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>
-rw-r--r-- | drivers/ide/ide-probe.c | 22 | ||||
-rw-r--r-- | include/linux/ide.h | 2 |
2 files changed, 9 insertions, 15 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index a3edbb5d0452..4b00945cf7d1 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; | ||
237 | err_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; |
540 | out_free: | ||
541 | kfree(drive->id); | ||
542 | return 0; | ||
547 | } | 543 | } |
548 | 544 | ||
549 | static void hwif_release_dev(struct device *dev) | 545 | static void hwif_release_dev(struct device *dev) |
diff --git a/include/linux/ide.h b/include/linux/ide.h index 47878719c56b..ab8ee4f32f52 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h | |||
@@ -494,8 +494,6 @@ enum { | |||
494 | IDE_DFLAG_NICE1 = (1 << 5), | 494 | IDE_DFLAG_NICE1 = (1 << 5), |
495 | /* device is physically present */ | 495 | /* device is physically present */ |
496 | IDE_DFLAG_PRESENT = (1 << 6), | 496 | IDE_DFLAG_PRESENT = (1 << 6), |
497 | /* device ejected hint */ | ||
498 | IDE_DFLAG_DEAD = (1 << 7), | ||
499 | /* id read from device (synthetic if not set) */ | 497 | /* id read from device (synthetic if not set) */ |
500 | IDE_DFLAG_ID_READ = (1 << 8), | 498 | IDE_DFLAG_ID_READ = (1 << 8), |
501 | IDE_DFLAG_NOPROBE = (1 << 9), | 499 | IDE_DFLAG_NOPROBE = (1 << 9), |