Re: [PATCH RESEND] PM: domains: Fix return value of API dev_pm_get_subsys_data()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2024/11/12 19:46, Greg Kroah-Hartman wrote:
> On Mon, Oct 28, 2024 at 08:31:11PM +0800, Zijun Hu wrote:
>> From: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>
>>
>> dev_pm_get_subsys_data() has below 2 issues under condition
>> (@dev->power.subsys_data != NULL):
>>
>> - it will do unnecessary kzalloc() and kfree().
> 
> But that's ok, everything still works, right?

yes.

> 
>> - it will return -ENOMEM if the kzalloc() fails, that is wrong
>>   since the kzalloc() is not needed.
> 
> But it's ok to return the proper error if the system is that broken.

IMO, the API should return 0 (success) instead of -ENOMEM since it does
not need to do kzalloc().

Different return value should impact caller's logic.

> 
>>
>> Fixed by not doing kzalloc() and returning 0 for the condition.
>>
>> Fixes: ef27bed1870d ("PM: Reference counting of power.subsys_data")
>> Cc: stable@xxxxxxxxxxxxxxx
> 
> Why is this relevant for stable kernels?

you can remove both Fix and stable tag directly if you like this change.(^^)

> 
> thanks,
> 
> greg k-h





[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux