]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
scsi: sun_esp: fix device reference leaks
authorJohan Hovold <johan@kernel.org>
Wed, 21 Jun 2017 09:35:09 +0000 (11:35 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 28 Jun 2017 01:46:55 +0000 (21:46 -0400)
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>
drivers/scsi/sun_esp.c

index 7b6d4c2087d7f67179343da8dace46ebb856d792..747ee64a78e1c98ddb67a58104351e92b95f029f 100644 (file)
@@ -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;
 }