Message ID | 20241007150852.2183722-4-andriy.shevchenko@linux.intel.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | dmaengine: dma_request_chan*() amendments | expand |
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. > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > --- > drivers/dma/dmaengine.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c > index c1357d7f3dc6..dd4224d90f07 100644 > --- a/drivers/dma/dmaengine.c > +++ b/drivers/dma/dmaengine.c > @@ -854,8 +854,8 @@ struct dma_chan *dma_request_chan(struct device *dev, const char *name) > > found: > #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 ... No funcational issue if it is NULL because user always test it before use. > #endif > > chan->name = kasprintf(GFP_KERNEL, "dma:%s", name); > -- > 2.43.0.rc1.1336.g36b5255a03ac >
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.
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index c1357d7f3dc6..dd4224d90f07 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c @@ -854,8 +854,8 @@ struct dma_chan *dma_request_chan(struct device *dev, const char *name) found: #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 */ #endif chan->name = kasprintf(GFP_KERNEL, "dma:%s", name);
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. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- drivers/dma/dmaengine.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)