Re: [PATCH v3 1/3] rpmsg: char: Remove put_device() in rpmsg_eptdev_add()

Zhongqiu Han
2025-11-14T13:40:34Z

On 11/14/2025 5:53 PM, Zhongqiu Han wrote:
> 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
>

The above link I arised was wrong; it’s now updated to the correct one.

https://git.kernel.org/pub/scm/linux/kernel/git/remoteproc/linux.git/tree/drivers/rpmsg/rpmsg_char.c?h=for-next#n476

> 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