All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Laight <david.laight.linux@gmail.com>
To: Frank Li <Frank.li@oss.nxp.com>
Cc: Greg KH <gregkh@linuxfoundation.org>,
	Xu Yang <xu.yang_2@oss.nxp.com>,
	kees@kernel.org, christophe.jaillet@wanadoo.fr,
	xu.yang_2@nxp.com, hataegu0826@gmail.com, balbi@ti.com,
	andrzej.p@samsung.com, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH] usb: gadget: f_uac1_legacy: fix inverted NULL check after kstrndup()
Date: Thu, 9 Jul 2026 17:39:45 +0100	[thread overview]
Message-ID: <20260709173945.268a9917@pumpkin> (raw)
In-Reply-To: <ak64635tgUj3MPEx@SMW015318>

On Wed, 8 Jul 2026 15:54:03 -0500
Frank Li <Frank.li@oss.nxp.com> wrote:

> On Wed, Jul 08, 2026 at 05:05:03PM +0200, Greg KH wrote:
> > On Thu, Jun 25, 2026 at 07:31:54PM +0800, Xu Yang wrote:  
> > > From: Xu Yang <xu.yang_2@nxp.com>
> > >
> > > kstrndup() returns NULL on allocation failure. The condition was
> > > checking 'if (tmp)' to detect failure, but this is inverted — it
> > > would treat a successful allocation as an error and return -ENOMEM
> > > while leaking the string, and proceed with a NULL pointer on failure.
> > >
> > > Fix by changing the condition to 'if (!tmp)'.
> > >
> > > Fixes: 0854611a19ae ("usb: gadget: f_uac1: add configfs support")
> > > Cc: stable@vger.kernel.org
> > > Assisted-by: Claude:claude-sonnet-4-6
> > > Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> > > ---
> > >  drivers/usb/gadget/function/f_uac1_legacy.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/usb/gadget/function/f_uac1_legacy.c b/drivers/usb/gadget/function/f_uac1_legacy.c
> > > index 5d201a2e30e7..e9f2632ce785 100644
> > > --- a/drivers/usb/gadget/function/f_uac1_legacy.c
> > > +++ b/drivers/usb/gadget/function/f_uac1_legacy.c
> > > @@ -914,7 +914,7 @@ static ssize_t f_uac1_opts_##name##_store(struct config_item *item,	\
> > >  		goto end;						\
> > >  									\
> > >  	tmp = kstrndup(page, len, GFP_KERNEL);				\
> > > -	if (tmp) {							\
> > > +	if (!tmp) {							\
> > >  		ret = -ENOMEM;						\
> > >  		goto end;						\
> > >  	}								\
> > > --
> > > 2.34.1
> > >
> > >  
> >
> > So this has never worked?  How has no one ever noticed that in the
> > decade this has been in the kernel?  Does that mean that no one uses
> > this file/driver and we can just remove it?  
> 
> I think just no one use sys interface to change name.

Or doesn't notice/care that is didn't work and didn't try often
enough to leak enough memory to break things.

	David

> 
> Frank
> 
> >
> > thanks,
> >
> > greg k-h
> >  
> 


      parent reply	other threads:[~2026-07-09 16:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-25 11:31 [PATCH] usb: gadget: f_uac1_legacy: fix inverted NULL check after kstrndup() Xu Yang
2026-06-25 11:40 ` sashiko-bot
2026-06-25 12:15 ` Frank Li
2026-07-08 15:05 ` Greg KH
2026-07-08 20:54   ` Frank Li
2026-07-09  5:33     ` Greg KH
2026-07-09  6:23       ` Xu Yang
2026-07-09  6:48         ` Greg KH
2026-07-10 12:58           ` Greg KH
2026-07-13  2:08             ` Xu Yang
2026-07-09 16:39     ` David Laight [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=20260709173945.268a9917@pumpkin \
    --to=david.laight.linux@gmail.com \
    --cc=Frank.li@oss.nxp.com \
    --cc=andrzej.p@samsung.com \
    --cc=balbi@ti.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=gregkh@linuxfoundation.org \
    --cc=hataegu0826@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=xu.yang_2@nxp.com \
    --cc=xu.yang_2@oss.nxp.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.