From: Miaoqian Lin <linmq006@gmail.com>
To: mathieu.poirier@linaro.org
Cc: alexander.shishkin@linux.intel.com, coresight@lists.linaro.org,
leo.yan@linaro.org, linmq006@gmail.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, mike.leach@linaro.org,
suzuki.poulose@arm.com
Subject: [PATCH v2] coresight: syscfg: Fix memleak on registration failure in cscfg_create_device
Date: Mon, 24 Jan 2022 12:41:21 +0000 [thread overview]
Message-ID: <20220124124121.8888-1-linmq006@gmail.com> (raw)
In-Reply-To: <20220120182822.GA1342128@p14s>
device_register() calls device_initialize(),
according to doc of device_initialize:
Use put_device() to give up your reference instead of freeing
* @dev directly once you have called this function.
To prevent potential memleak, use put_device() for error handling.
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
Changes in v2:
- simply call put_device() instead of cscfg_dev_release() in the error
path of cscfg_create_device.
---
drivers/hwtracing/coresight/coresight-syscfg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hwtracing/coresight/coresight-syscfg.c b/drivers/hwtracing/coresight/coresight-syscfg.c
index 43054568430f..c30989e0675f 100644
--- a/drivers/hwtracing/coresight/coresight-syscfg.c
+++ b/drivers/hwtracing/coresight/coresight-syscfg.c
@@ -791,7 +791,7 @@ static int cscfg_create_device(void)
err = device_register(dev);
if (err)
- cscfg_dev_release(dev);
+ put_device(dev);
create_dev_exit_unlock:
mutex_unlock(&cscfg_mutex);
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-01-24 12:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-10 7:31 [PATCH] coresight: syscfg: Fix memleak on registration failure in cscfg_create_device Miaoqian Lin
2022-01-20 17:56 ` Mathieu Poirier
2022-01-20 18:28 ` Mathieu Poirier
2022-01-24 12:41 ` Miaoqian Lin [this message]
2022-02-01 17:13 ` [PATCH v2] " Mathieu Poirier
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=20220124124121.8888-1-linmq006@gmail.com \
--to=linmq006@gmail.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=coresight@lists.linaro.org \
--cc=leo.yan@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=mike.leach@linaro.org \
--cc=suzuki.poulose@arm.com \
/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).