mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
To: Dawei Li <dawei.li@linux.dev>,
	andersson@kernel.org, mathieu.poirier@linaro.org
Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org,
	set_pte_at@outlook.com, stable@vger.kernel.org,
	zhongqiu.han@oss.qualcomm.com
Subject: Re: [PATCH v3 1/3] rpmsg: char: Remove put_device() in rpmsg_eptdev_add()
Date: Fri, 14 Nov 2025 17:53:14 +0800	[thread overview]
Message-ID: <b754155b-a17b-4e8e-92b7-8ab37949dded@oss.qualcomm.com> (raw)
In-Reply-To: <20251113153909.3789-2-dawei.li@linux.dev>

On 11/13/2025 11:39 PM, Dawei Li wrote:
> put_device() is called on error path of rpmsg_eptdev_add() to cleanup
> resource attached to eptdev->dev, unfortunately it's bogus cause
> dev->release() is not set yet.
> 
> When a struct device instance is destroyed, driver core framework checks
> the possible release() callback from candidates below:
> - struct device::release()
> - dev->type->release()
> - dev->class->dev_release()
> 
> Rpmsg eptdev owns none of them so WARN() will complaint the absence of
> release():

Hi Dawei,


> 
> [  159.112182] ------------[ cut here ]------------
> [  159.112188] Device '(null)' does not have a release() function, it is broken and must be fixed. See Documentation/core-api/kobject.rst.
> [  159.112205] WARNING: CPU: 2 PID: 1975 at drivers/base/core.c:2567 device_release+0x7a/0x90
> 


Although my local checkpatch.pl didn’t complain about this log line
exceeding 75 characters, could we simplify it or just provide a summary
instead?


> Fixes: c0cdc19f84a4 ("rpmsg: Driver for user space endpoint interface")
> Cc: stable@vger.kernel.org
> Signed-off-by: Dawei Li <dawei.li@linux.dev>
> ---
>   drivers/rpmsg/rpmsg_char.c | 1 -
>   1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c
> index 34b35ea74aab..1b8297b373f0 100644
> --- a/drivers/rpmsg/rpmsg_char.c
> +++ b/drivers/rpmsg/rpmsg_char.c
> @@ -494,7 +494,6 @@ static int rpmsg_eptdev_add(struct rpmsg_eptdev *eptdev,
>   	if (cdev)
>   		ida_free(&rpmsg_minor_ida, MINOR(dev->devt));
>   free_eptdev:
> -	put_device(dev);


Yes, remove put_device can solve the warning issue, however it would
introduce one memleak issue of kobj->name.

https://git.kernel.org/pub/scm/linux/kernel/git/remoteproc/linux.git/tree/drivers/rpmsg/rpmsg_char.c#n381 


dev_set_name(dev, "rpmsg%d", ret); is already called, it depends on
put_device to free memory, right?


>   	kfree(eptdev);
>   
>   	return ret;


-- 
Thx and BRs,
Zhongqiu Han

  reply	other threads:[~2025-11-14  9:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-13 15:39 [PATCH v3 0/3] Fix and rework of rpmsg_eptdev_add() Dawei Li
2025-11-13 15:39 ` [PATCH v3 1/3] rpmsg: char: Remove put_device() in rpmsg_eptdev_add() Dawei Li
2025-11-14  9:53   ` Zhongqiu Han [this message]
2025-11-14 13:40     ` Zhongqiu Han
2025-11-14 14:23     ` Dawei Li
2025-11-13 15:39 ` [PATCH v3 2/3] rpmsg: char: Fix UAF and memory leak in rpmsg_anonymous_eptdev_create() Dawei Li
2025-11-14 19:01   ` Mathieu Poirier
2025-11-13 15:39 ` [PATCH v3 3/3] rpmsg: char: Rework exception handling of rpmsg_eptdev_add() Dawei Li
2025-11-14  9:53   ` Zhongqiu Han
2025-11-14 19:04   ` 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=b754155b-a17b-4e8e-92b7-8ab37949dded@oss.qualcomm.com \
    --to=zhongqiu.han@oss.qualcomm.com \
    --cc=andersson@kernel.org \
    --cc=dawei.li@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=set_pte_at@outlook.com \
    --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

all inboxes | Powered by JetHome®