Re: [PATCH v1 3/4] dmaengine: Add a comment on why it's okay when kasprintf() fails

From: Andy Shevchenko
Date: Tue Oct 08 2024 - 13:16:23 EST


On Mon, Oct 07, 2024 at 11:51:14AM -0400, Frank Li wrote:
> On Mon, Oct 07, 2024 at 06:06:47PM +0300, Andy Shevchenko wrote:
> > In dma_request_chan() one of the kasprintf() call is not checked
> > against NULL. This is completely fine right now, but make others
> > aware of this aspect by adding a comment.
>
> suggest:
>
> Add comment in dma_request_chan() to clarify kasprintf() missing return
> value check and it is correct funcationaly.

Sure, thanks.

...

> > #ifdef CONFIG_DEBUG_FS
> > - chan->dbg_client_name = kasprintf(GFP_KERNEL, "%s:%s", dev_name(dev),
> > - name);
> > + chan->dbg_client_name = kasprintf(GFP_KERNEL, "%s:%s", dev_name(dev), name);
> > + /* No functional issue if it fails, users are supposed to test before use */
>
> comments should above chan->dbg_client_name ...

It's placed exactly there on purpose. Because it explains

> No funcational issue if it is NULL because user always test it before use.

I think my is better because it reveals the actual issue, ideally users
must not rely on that and the code here should assign a valid pointer.
The problem is that the code paths are a bit twisted and I only can come
up with this comment _for now_. Semantically this change is a band-aid
(and not good), but at least it describes current (broken) desing.

--
With Best Regards,
Andy Shevchenko