Commit 6a2db7f2 authored by Miaoqian Lin's avatar Miaoqian Lin Committed by Zizhi Wo
Browse files

ata: pata_octeon_cf: Fix refcount leak in octeon_cf_probe

stable inclusion
from stable-v4.19.247
commit 8d8ad067b90f231b8fdb14acee673ca4012f6045
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IBPBXX
CVE: CVE-2022-49354

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=8d8ad067b90f231b8fdb14acee673ca4012f6045



--------------------------------

[ Upstream commit 10d6bdf5 ]

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: 43f01da0 ("MIPS/OCTEON/ata: Convert pata_octeon_cf.c to use device tree.")
Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
Reviewed-by: default avatarSergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>

Conflicts:
	drivers/ata/pata_octeon_cf.c.rej
[Simple context conflict, no practical impact.]
Signed-off-by: default avatarZizhi Wo <wozizhi@huawei.com>
parent 3e8e3ea7
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -888,12 +888,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_nocache(&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;
				}
@@ -902,6 +904,7 @@ static int octeon_cf_probe(struct platform_device *pdev)
				i = platform_get_irq(dma_dev, 0);
				if (i > 0)
					irq = i;
				put_device(&dma_dev->dev);
			}
			of_node_put(dma_node);
		}