public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: lee@kernel.org
Cc: stable@vger.kernel.org, Hangyu Hua <hbh25y@gmail.com>,
	Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	Mathieu Poirier <mathieu.poirier@linaro.org>
Subject: [PATCH v4.19.y 6/6] rpmsg: Fix possible refcount leak in rpmsg_register_device_override()
Date: Tue, 31 Oct 2023 09:30:15 +0000	[thread overview]
Message-ID: <20231031093018.2233640-6-lee@kernel.org> (raw)
In-Reply-To: <20231031093018.2233640-1-lee@kernel.org>

From: Hangyu Hua <hbh25y@gmail.com>

commit d7bd416d35121c95fe47330e09a5c04adbc5f928 upstream.

rpmsg_register_device_override need to call put_device to free vch when
driver_set_override fails.

Fix this by adding a put_device() to the error path.

Fixes: bb17d110cbf2 ("rpmsg: Fix calling device_lock() on non-initialized device")
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
Link: https://lore.kernel.org/r/20220624024120.11576-1-hbh25y@gmail.com
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Lee Jones <lee@kernel.org>
Change-Id: I38b3e338ed57bc27d8818be9c166f52762973db3
---
 drivers/rpmsg/rpmsg_core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c
index 3d6427b0edc41..880c7c4deec30 100644
--- a/drivers/rpmsg/rpmsg_core.c
+++ b/drivers/rpmsg/rpmsg_core.c
@@ -550,6 +550,7 @@ int rpmsg_register_device_override(struct rpmsg_device *rpdev,
 					  strlen(driver_override));
 		if (ret) {
 			dev_err(dev, "device_set_override failed: %d\n", ret);
+			put_device(dev);
 			return ret;
 		}
 	}
-- 
2.42.0.820.g83a721a137-goog


  parent reply	other threads:[~2023-10-31  9:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-31  9:30 [PATCH v4.19.y 1/6] driver: platform: Add helper for safer setting of driver_override Lee Jones
2023-10-31  9:30 ` [PATCH v4.19.y 2/6] rpmsg: Constify local variable in field store macro Lee Jones
2023-10-31  9:30 ` [PATCH v4.19.y 3/6] rpmsg: Fix kfree() of static memory on setting driver_override Lee Jones
2023-10-31  9:30 ` [PATCH v4.19.y 4/6] rpmsg: Fix calling device_lock() on non-initialized device Lee Jones
2023-10-31  9:30 ` [PATCH v4.19.y 5/6] rpmsg: glink: Release driver_override Lee Jones
2023-10-31  9:30 ` Lee Jones [this message]
2023-10-31  9:36 ` [PATCH v4.19.y 1/6] driver: platform: Add helper for safer setting of driver_override Lee Jones
  -- strict thread matches above, loose matches on Subject: below --
2023-10-31 11:39 Lee Jones
2023-10-31 11:39 ` [PATCH v4.19.y 6/6] rpmsg: Fix possible refcount leak in rpmsg_register_device_override() Lee Jones

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=20231031093018.2233640-6-lee@kernel.org \
    --to=lee@kernel.org \
    --cc=hbh25y@gmail.com \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=stable@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