public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Miaoqian Lin <linmq006@gmail.com>
Cc: linmq006@gmail.com, Daniel Mack <daniel@zonque.org>,
	Haojian Zhuang <haojian.zhuang@gmail.com>,
	Robert Jarzmik <robert.jarzmik@free.fr>,
	Russell King <linux@armlinux.org.uk>,
	Marc Zyngier <marc.zyngier@altran.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] ARM: pxa: Fix error handling in viper_tpm_init
Date: Mon, 27 Dec 2021 12:51:53 +0000	[thread overview]
Message-ID: <20211227125154.3145-1-linmq006@gmail.com> (raw)

tpm_device get by platform_device_alloc(), which calls device_initialize.
Call platform_device_put(tpm_device) instead of kfree(tmp_device) to
prevent memory leak.

Fixes: 352699a ("Basic support for the Arcom/Eurotech Viper SBC.")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 arch/arm/mach-pxa/viper.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-pxa/viper.c b/arch/arm/mach-pxa/viper.c
index 3aa34e9a15d3..9a0f184dbecb 100644
--- a/arch/arm/mach-pxa/viper.c
+++ b/arch/arm/mach-pxa/viper.c
@@ -815,11 +815,11 @@ static void __init viper_tpm_init(void)
 					      sizeof(i2c_tpm_data))) {
 			if (platform_device_add(tpm_device)) {
 				errstr = "register TPM i2c bus";
-				goto error_free_tpm;
+				goto exit_put_device;
 			}
 		} else {
 			errstr = "allocate TPM i2c bus data";
-			goto error_free_tpm;
+			goto exit_put_device;
 		}
 	} else {
 		errstr = "allocate TPM i2c device";
@@ -827,9 +827,8 @@ static void __init viper_tpm_init(void)
 	}
 
 	return;
-
-error_free_tpm:
-	kfree(tpm_device);
+exit_put_device:
+	platform_device_put(tpm_device);
 error_tpm:
 	pr_err("viper: Couldn't %s, giving up\n", errstr);
 }
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

             reply	other threads:[~2021-12-27 12:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-27 12:51 Miaoqian Lin [this message]
2021-12-27 15:34 ` [PATCH] ARM: pxa: Fix error handling in viper_tpm_init Daniel Mack

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=20211227125154.3145-1-linmq006@gmail.com \
    --to=linmq006@gmail.com \
    --cc=daniel@zonque.org \
    --cc=haojian.zhuang@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=marc.zyngier@altran.com \
    --cc=robert.jarzmik@free.fr \
    /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