summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2017-06-21 11:35:09 +0200
committerBen Hutchings <ben@decadent.org.uk>2017-10-12 15:27:53 +0100
commit8014e2c2bab92b1be8c8172f644986e0bb7d6c83 (patch)
treee62a016c4f089f3172eaf5bd34b246675a8b87d8
parent1653d793b621418b0796d6c6f4ef15a0b839c975 (diff)
downloadlinux-stable-8014e2c2bab92b1be8c8172f644986e0bb7d6c83.tar.gz
linux-stable-8014e2c2bab92b1be8c8172f644986e0bb7d6c83.tar.bz2
linux-stable-8014e2c2bab92b1be8c8172f644986e0bb7d6c83.zip
scsi: sun_esp: fix device reference leaks
commit f62f9ffdb5ef683ef8cffb43932fa72cc3713e94 upstream. Make sure to drop the reference to the dma device taken by of_find_device_by_node() on probe errors and on driver unbind. Fixes: 334ae614772b ("sparc: Kill SBUS DVMA layer.") Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r--drivers/scsi/sun_esp.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/scsi/sun_esp.c b/drivers/scsi/sun_esp.c
index f2e68459f7ea..6585d75bf732 100644
--- a/drivers/scsi/sun_esp.c
+++ b/drivers/scsi/sun_esp.c
@@ -566,6 +566,7 @@ static int esp_sbus_probe(struct platform_device *op)
struct device_node *dp = op->dev.of_node;
struct platform_device *dma_of = NULL;
int hme = 0;
+ int ret;
if (dp->parent &&
(!strcmp(dp->parent->name, "espdma") ||
@@ -580,7 +581,11 @@ static int esp_sbus_probe(struct platform_device *op)
if (!dma_of)
return -ENODEV;
- return esp_sbus_probe_one(op, dma_of, hme);
+ ret = esp_sbus_probe_one(op, dma_of, hme);
+ if (ret)
+ put_device(&dma_of->dev);
+
+ return ret;
}
static int esp_sbus_remove(struct platform_device *op)
@@ -613,6 +618,8 @@ static int esp_sbus_remove(struct platform_device *op)
dev_set_drvdata(&op->dev, NULL);
+ put_device(&dma_of->dev);
+
return 0;
}