From ba5787323d38084b30261e84510d4a173fcb493a Mon Sep 17 00:00:00 2001 From: Mariusz Kozlowski Date: Mon, 22 Nov 2010 11:37:21 -0800 Subject: [PATCH 1/5] ide: fix use after free in ide-acpi out_obj points to kfreed memory and we dereference that pointer in DEBPRINT/printk. Signed-off-by: Mariusz Kozlowski Signed-off-by: David S. Miller --- drivers/ide/ide-acpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c index c26c11905ffe..2af8cb460a3b 100644 --- a/drivers/ide/ide-acpi.c +++ b/drivers/ide/ide-acpi.c @@ -416,21 +416,21 @@ void ide_acpi_get_timing(ide_hwif_t *hwif) out_obj = output.pointer; if (out_obj->type != ACPI_TYPE_BUFFER) { - kfree(output.pointer); DEBPRINT("Run _GTM: error: " "expected object type of ACPI_TYPE_BUFFER, " "got 0x%x\n", out_obj->type); + kfree(output.pointer); return; } if (!out_obj->buffer.length || !out_obj->buffer.pointer || out_obj->buffer.length != sizeof(struct GTM_buffer)) { - kfree(output.pointer); printk(KERN_ERR "%s: unexpected _GTM length (0x%x)[should be 0x%zx] or " "addr (0x%p)\n", __func__, out_obj->buffer.length, sizeof(struct GTM_buffer), out_obj->buffer.pointer); + kfree(output.pointer); return; } From f2ba70a22c31a179226fa0517729104497a7853f Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Mon, 22 Nov 2010 11:38:08 -0800 Subject: [PATCH 2/5] drivers/ide/pmac.c: Remove unnecessary casts of pci_get_drvdata Signed-off-by: Joe Perches Signed-off-by: David S. Miller --- drivers/ide/pmac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/ide/pmac.c b/drivers/ide/pmac.c index ebcf8e470a97..1db7c4368dbf 100644 --- a/drivers/ide/pmac.c +++ b/drivers/ide/pmac.c @@ -1334,7 +1334,7 @@ out_free_pmif: static int pmac_ide_pci_suspend(struct pci_dev *pdev, pm_message_t mesg) { - pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)pci_get_drvdata(pdev); + pmac_ide_hwif_t *pmif = pci_get_drvdata(pdev); int rc = 0; if (mesg.event != pdev->dev.power.power_state.event @@ -1350,7 +1350,7 @@ pmac_ide_pci_suspend(struct pci_dev *pdev, pm_message_t mesg) static int pmac_ide_pci_resume(struct pci_dev *pdev) { - pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)pci_get_drvdata(pdev); + pmac_ide_hwif_t *pmif = pci_get_drvdata(pdev); int rc = 0; if (pdev->dev.power.power_state.event != PM_EVENT_ON) { From f17bfe79e6aa34aecbd579258a5c55a790807aca Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Mon, 22 Nov 2010 11:39:30 -0800 Subject: [PATCH 3/5] IDE: ide-floppy, remove unnecessary NULL check Stanse found that rq in ide_floppy_callback cannot be NULL, because it is dereferenced all around. So remove the superfluous check. This appeared after blk_* macros removal. Signed-off-by: Jiri Slaby Signed-off-by: David S. Miller --- drivers/ide/ide-floppy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 5406b6ea3ad1..536ff68062ab 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -73,7 +73,7 @@ static int ide_floppy_callback(ide_drive_t *drive, int dsc) drive->failed_pc = NULL; if (pc->c[0] == GPCMD_READ_10 || pc->c[0] == GPCMD_WRITE_10 || - (rq && rq->cmd_type == REQ_TYPE_BLOCK_PC)) + rq->cmd_type == REQ_TYPE_BLOCK_PC) uptodate = 1; /* FIXME */ else if (pc->c[0] == GPCMD_REQUEST_SENSE) { From 245e37182b7dead255bdc9e333e0bcc128360675 Mon Sep 17 00:00:00 2001 From: Anton Blanchard Date: Sun, 8 May 2011 16:41:45 -0700 Subject: [PATCH 4/5] ide: Use linux/mutex.h The IDE code is still including asm/mutex.h instead of linux/mutex.h Signed-off-by: Anton Blanchard Signed-off-by: David S. Miller --- include/linux/ide.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/ide.h b/include/linux/ide.h index 072fe8c93e6f..42557851b12e 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -18,13 +18,13 @@ #include #include #include +#include #ifdef CONFIG_BLK_DEV_IDEACPI #include #endif #include #include #include -#include /* for request_sense */ #include From db210f824c2f155703edf03bc2137da1bd76e27d Mon Sep 17 00:00:00 2001 From: Thiago Farina Date: Sun, 1 May 2011 12:10:25 +0000 Subject: [PATCH 5/5] ide/ide-scan-pci.c: Use for_each_pci_dev(). Use for_each_pci_dev() to simplify the code. Signed-off-by: Thiago Farina Signed-off-by: David S. Miller --- drivers/ide/ide-scan-pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ide/ide-scan-pci.c b/drivers/ide/ide-scan-pci.c index 0e79efff1deb..c3da53e7bb2b 100644 --- a/drivers/ide/ide-scan-pci.c +++ b/drivers/ide/ide-scan-pci.c @@ -88,7 +88,7 @@ static int __init ide_scan_pcibus(void) struct list_head *l, *n; pre_init = 0; - while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev))) + for_each_pci_dev(dev) ide_scan_pcidev(dev); /*