ata: pata_octeon_cf: Fix refcount leak in octeon_cf_probe
authorMiaoqian Lin <linmq006@gmail.com>
Wed, 1 Jun 2022 08:59:26 +0000 (12:59 +0400)
committerDamien Le Moal <damien.lemoal@opensource.wdc.com>
Mon, 6 Jun 2022 00:52:17 +0000 (09:52 +0900)
of_find_device_by_node() takes reference, we should use put_device()
to release it when not need anymore.
Add missing put_device() to avoid refcount leak.

Fixes: 43f01da0f279 ("MIPS/OCTEON/ata: Convert pata_octeon_cf.c to use device tree.")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
drivers/ata/pata_octeon_cf.c

index 6b5ed30..35608a0 100644 (file)
@@ -856,12 +856,14 @@ static int octeon_cf_probe(struct platform_device *pdev)
                                int i;
                                res_dma = platform_get_resource(dma_dev, IORESOURCE_MEM, 0);
                                if (!res_dma) {
+                                       put_device(&dma_dev->dev);
                                        of_node_put(dma_node);
                                        return -EINVAL;
                                }
                                cf_port->dma_base = (u64)devm_ioremap(&pdev->dev, res_dma->start,
                                                                         resource_size(res_dma));
                                if (!cf_port->dma_base) {
+                                       put_device(&dma_dev->dev);
                                        of_node_put(dma_node);
                                        return -EINVAL;
                                }
@@ -871,6 +873,7 @@ static int octeon_cf_probe(struct platform_device *pdev)
                                        irq = i;
                                        irq_handler = octeon_cf_interrupt;
                                }
+                               put_device(&dma_dev->dev);
                        }
                        of_node_put(dma_node);
                }