lkml.org 
[lkml]   [2023]   [Aug]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v1 1/1] irqdomain: Refactor error path in __irq_domain_alloc_fwnode()
On Fri, Aug 04, 2023 at 06:33:07PM +0100, Marc Zyngier wrote:
> On 2023-08-04 17:49, Andy Shevchenko wrote:
> > First of all, there is no need to call kasprintf() if the previous
> > allocation failed. Second, there is no need to call for kfree()
> > when we know that its parameter is NULL. Refactor the code accordingly.

...

> > n = kasprintf(GFP_KERNEL, "irqchip@%pa", pa);
> > break;
> > }
> > -
> > - if (!fwid || !n) {
> > + if (!n) {
> > kfree(fwid);
> > - kfree(n);
> > return NULL;
> > }
>
> What are you trying to fix?

I'm not trying to fix anything (there is no such statement from me),
but I would think of some micro-optimization (speedup boot for
unnoticeable time? Dunno.).

> We have a common error handling path, which makes it easy to
> track the memory management. I don't think this sort of bike
> shedding adds much to the maintainability of this code.

Your call, of course, but I not often see in the kernel two or three attempts
to allocate some memory and have grouped check for the failure.

> Now if you have spotted an actual bug, I'm all ears.

--
With Best Regards,
Andy Shevchenko


\
 
 \ /
  Last update: 2023-08-04 22:12    [W:0.040 / U:0.148 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site