linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Osama Abdelkader <osama.abdelkader@gmail.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: jirislaby@kernel.org, andriy.shevchenko@linux.intel.com,
	elder@riscstar.com, benjamin.larsson@genexis.eu,
	u.kleine-koenig@baylibre.com, linux-kernel@vger.kernel.org,
	linux-serial@vger.kernel.org
Subject: Re: [PATCH] serial: 8250_of: replace kzalloc with devm_kzalloc
Date: Fri, 29 Aug 2025 16:19:10 +0200	[thread overview]
Message-ID: <2c6a3bc2-abd3-4d57-99e9-1c341c13d554@gmail.com> (raw)
In-Reply-To: <2025082908-charbroil-saline-ef5f@gregkh>


On 8/29/25 2:44 PM, Greg KH wrote:
> On Fri, Aug 29, 2025 at 11:49:41AM +0200, Osama Abdelkader wrote:
>> 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.
> But there are no existing errors, so why change working code?
>
>> It also aligns the driver with others in the 8250 subsystem which 
>> already use devm-managed resources.
> This code is older than the devm api :)
>
>> 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.
> But did you test the error paths?  That is what you changed here.
>
> And changes like this, for old, working, code, is usually not needed
> unless you are fixing a bug somewhere.
>
> thanks,
>
> greg k-h

Thanks Greg, totally understandable. I was looking for a simple patch to be honest
though looked for modernizing some APIs but looks like I chose the wrong driver:D
If you guide me to a simple bug or a simple contribution here would be much appreciated.

Thanks,
Osama


      reply	other threads:[~2025-08-29 14:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-27 23:11 [PATCH] serial: 8250_of: replace kzalloc with devm_kzalloc Osama Abdelkader
2025-08-28  5:51 ` Greg KH
2025-08-29  9:49   ` Osama Abdelkader
2025-08-29 12:44     ` Greg KH
2025-08-29 14:19       ` Osama Abdelkader [this message]

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=2c6a3bc2-abd3-4d57-99e9-1c341c13d554@gmail.com \
    --to=osama.abdelkader@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=benjamin.larsson@genexis.eu \
    --cc=elder@riscstar.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=u.kleine-koenig@baylibre.com \
    /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;
as well as URLs for NNTP newsgroup(s).