Re: [PATCH] serial: 8250_of: replace kzalloc with devm_kzalloc
From: Osama Abdelkader
Date: Fri Aug 29 2025 - 05:50:04 EST
On 8/28/25 7:51 AM, Greg KH wrote:
> On Thu, Aug 28, 2025 at 01:11:05AM +0200, Osama Abdelkader wrote:
>> Use devm_kzalloc for automatic memory cleanup.
> Why?
>
> I do not see a good reason here as to how this makes anything better
> overall? How was it tested?
>
> thanks,
>
> greg k-h
Hi Greg,
Thanks for the feedback, the change to devm_kzalloc ensures the allocated
memory is tied to the device's lifetime. This removed the need for explicit
kfree() calls in the remove path and avoids potential leaks in probe error
paths. It also aligns the driver with others in the 8250 subsystem which
already use devm-managed resources.
For testing, I built the kernel and booted it on QEMU riscv with of_serial
enabled. The driver probed successfully and the serial console worked as
expected, also tested unbinding/rebinding the driver via sysfs to confirm
no leaks or errors occur.
Thanks,
Osama