linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: gxt@pku.edu.cn, arnd@arndb.de
Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org,
	Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Subject: [PATCH] i2c: puv3: Fix an error handling path in 'puv3_i2c_probe()'
Date: Wed,  6 May 2020 05:28:24 +0200	[thread overview]
Message-ID: <20200506032824.191633-1-christophe.jaillet@wanadoo.fr> (raw)

There is a spurious 'put_device()' in the remove function.
A reference to 'pdev->dev' is taken in the probe function without a
corresponding 'get_device()' to increment the refcounted reference.

Add the missing 'get_device()' and update the error handling path
accordingly.

Fixes: d10e4a660d11 ("unicore32 machine related files: add i2c bus drivers for pkunity-v3 soc")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
This patch is provided as-is. It is not even compile tested because I don't
use cross-compiler.

It is purely speculative and based on what looks like an unbalanced
'put_device()' in the remove function.
---
 drivers/i2c/busses/i2c-puv3.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-puv3.c b/drivers/i2c/busses/i2c-puv3.c
index 5cec5a36807d..62a4b860d3c0 100644
--- a/drivers/i2c/busses/i2c-puv3.c
+++ b/drivers/i2c/busses/i2c-puv3.c
@@ -203,18 +203,20 @@ static int puv3_i2c_probe(struct platform_device *pdev)
 			mem->start);
 	adapter->algo = &puv3_i2c_algorithm;
 	adapter->class = I2C_CLASS_HWMON;
-	adapter->dev.parent = &pdev->dev;
+	adapter->dev.parent = get_device(&pdev->dev);
 
 	platform_set_drvdata(pdev, adapter);
 
 	adapter->nr = pdev->id;
 	rc = i2c_add_numbered_adapter(adapter);
 	if (rc)
-		goto fail_add_adapter;
+		goto fail_put_device;
 
 	dev_info(&pdev->dev, "PKUnity v3 i2c bus adapter.\n");
 	return 0;
 
+fail_put_device:
+	put_device(&pdev->dev);
 fail_add_adapter:
 	kfree(adapter);
 fail_nomem:
-- 
2.25.1


             reply	other threads:[~2020-05-06  3:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-06  3:28 Christophe JAILLET [this message]
2020-05-06 15:12 [PATCH] i2c: puv3: Fix an error handling path in puv3_i2c_probe() Markus Elfring

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=20200506032824.191633-1-christophe.jaillet@wanadoo.fr \
    --to=christophe.jaillet@wanadoo.fr \
    --cc=arnd@arndb.de \
    --cc=gxt@pku.edu.cn \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).