Linux ATA/IDE development
 help / color / mirror / Atom feed
From: Miaoqian Lin <linmq006@gmail.com>
To: Sergey Shtylyov <s.shtylyov@omp.ru>,
	Damien Le Moal <damien.lemoal@opensource.wdc.com>,
	Jeff Garzik <jgarzik@redhat.com>,
	David Daney <david.daney@cavium.com>,
	linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: linmq006@gmail.com
Subject: [PATCH] ata: pata_octeon_cf: Fix refcount leak in octeon_cf_probe
Date: Wed, 11 May 2022 10:27:23 +0400	[thread overview]
Message-ID: <20220511062723.56652-1-linmq006@gmail.com> (raw)

of_find_device_by_node() takes reference, we should use put_device()
to release it when not need anymore.
Add missing put_device() in error path 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>
---
 drivers/ata/pata_octeon_cf.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/ata/pata_octeon_cf.c b/drivers/ata/pata_octeon_cf.c
index 6b5ed3046b44..65688459acf1 100644
--- a/drivers/ata/pata_octeon_cf.c
+++ b/drivers/ata/pata_octeon_cf.c
@@ -857,12 +857,14 @@ static int octeon_cf_probe(struct platform_device *pdev)
 				res_dma = platform_get_resource(dma_dev, IORESOURCE_MEM, 0);
 				if (!res_dma) {
 					of_node_put(dma_node);
+					put_device(&dma_dev->dev);
 					return -EINVAL;
 				}
 				cf_port->dma_base = (u64)devm_ioremap(&pdev->dev, res_dma->start,
 									 resource_size(res_dma));
 				if (!cf_port->dma_base) {
 					of_node_put(dma_node);
+					put_device(&dma_dev->dev);
 					return -EINVAL;
 				}
 
-- 
2.25.1


             reply	other threads:[~2022-05-11  6:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-11  6:27 Miaoqian Lin [this message]
2022-05-11  7:36 ` [PATCH] ata: pata_octeon_cf: Fix refcount leak in octeon_cf_probe Damien Le Moal
2022-05-11 11:46 ` Sergey Shtylyov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220511062723.56652-1-linmq006@gmail.com \
    --to=linmq006@gmail.com \
    --cc=damien.lemoal@opensource.wdc.com \
    --cc=david.daney@cavium.com \
    --cc=jgarzik@redhat.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=s.shtylyov@omp.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox