All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hangyu Hua <hbh25y@gmail.com>
To: alexander.shishkin@linux.intel.com, mcoquelin.stm32@gmail.com,
	alexandre.torgue@foss.st.com, gregkh@linuxfoundation.org,
	mathieu.poirier@linaro.org
Cc: linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Hangyu Hua <hbh25y@gmail.com>
Subject: [PATCH] hwtracing: stm: fix possible double free in stm_register_device()
Date: Mon, 18 Apr 2022 16:16:32 +0800	[thread overview]
Message-ID: <20220418081632.35121-1-hbh25y@gmail.com> (raw)

put_device() will call stm_device_release() to free stm when
stm_register_device() fails. So there is no need to call vfree() again.

Fix this by adding a return after put_device().

Fixes: 7bd1d4093c2f ("stm class: Introduce an abstraction for System Trace Module devices")
Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
---
 drivers/hwtracing/stm/core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c
index 2712e699ba08..403b4f41bb1b 100644
--- a/drivers/hwtracing/stm/core.c
+++ b/drivers/hwtracing/stm/core.c
@@ -915,6 +915,7 @@ int stm_register_device(struct device *parent, struct stm_data *stm_data,
 
 	/* matches device_initialize() above */
 	put_device(&stm->dev);
+	return err;
 err_free:
 	vfree(stm);
 
-- 
2.25.1


WARNING: multiple messages have this Message-ID (diff)
From: Hangyu Hua <hbh25y@gmail.com>
To: alexander.shishkin@linux.intel.com, mcoquelin.stm32@gmail.com,
	alexandre.torgue@foss.st.com, gregkh@linuxfoundation.org,
	mathieu.poirier@linaro.org
Cc: linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Hangyu Hua <hbh25y@gmail.com>
Subject: [PATCH] hwtracing: stm: fix possible double free in stm_register_device()
Date: Mon, 18 Apr 2022 16:16:32 +0800	[thread overview]
Message-ID: <20220418081632.35121-1-hbh25y@gmail.com> (raw)

put_device() will call stm_device_release() to free stm when
stm_register_device() fails. So there is no need to call vfree() again.

Fix this by adding a return after put_device().

Fixes: 7bd1d4093c2f ("stm class: Introduce an abstraction for System Trace Module devices")
Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
---
 drivers/hwtracing/stm/core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c
index 2712e699ba08..403b4f41bb1b 100644
--- a/drivers/hwtracing/stm/core.c
+++ b/drivers/hwtracing/stm/core.c
@@ -915,6 +915,7 @@ int stm_register_device(struct device *parent, struct stm_data *stm_data,
 
 	/* matches device_initialize() above */
 	put_device(&stm->dev);
+	return err;
 err_free:
 	vfree(stm);
 
-- 
2.25.1


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

             reply	other threads:[~2022-04-18  8:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-18  8:16 Hangyu Hua [this message]
2022-04-18  8:16 ` [PATCH] hwtracing: stm: fix possible double free in stm_register_device() Hangyu Hua
2022-05-05  1:29 ` Hangyu Hua
2022-05-05  1:29   ` Hangyu Hua
2022-05-23  1:55   ` Hangyu Hua
2022-05-23  1:55     ` Hangyu Hua
2022-06-23  1:44     ` Hangyu Hua
2022-06-23  1:44       ` Hangyu Hua

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=20220418081632.35121-1-hbh25y@gmail.com \
    --to=hbh25y@gmail.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mathieu.poirier@linaro.org \
    --cc=mcoquelin.stm32@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.