The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Xu Yang <xu.yang_2@oss.nxp.com>
Cc: Frank Li <Frank.li@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: Fri, 10 Jul 2026 14:58:02 +0200	[thread overview]
Message-ID: <2026071019-parkway-captivate-086f@gregkh> (raw)
In-Reply-To: <2026070908-semisweet-parabola-4a48@gregkh>

On Thu, Jul 09, 2026 at 08:48:08AM +0200, Greg KH wrote:
> On Thu, Jul 09, 2026 at 02:23:51PM +0800, Xu Yang wrote:
> > On Thu, Jul 09, 2026 at 07:33:03AM +0200, Greg KH wrote:
> > > On Wed, Jul 08, 2026 at 03:54:03PM -0500, Frank Li 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.
> > > 
> > > So it can just be removed?  Please submit a patch to do that instead.
> > > 
> > > Ideally this whole file can be removed, does anyone still use it?
> > 
> > This legacy driver is still built in kernel in multi_v7_defconfig: 
> > 
> > ~/work/usb$ grep -nr CONFIG_USB_CONFIGFS_F_UAC1_LEGACY arch/*/configs/
> > arch/arm/configs/multi_v7_defconfig:939:CONFIG_USB_CONFIGFS_F_UAC1_LEGACY=y
> 
> defconfig doesn't mean much.  Perhaps look at some of the Android
> configs?
> 
> > It seems we can't simply remove it. 
> 
> Why?
> 
> > BTW, do we have other ways to figure out if it can be removed?
> 
> Remove it and see who complains?  :)

Seriously, let's remove the ability to set the name as that has never
worked.  If anyone wants it to work, they can make a new patch to add
that feature as a new one.

thanks,

greg k-h

  reply	other threads:[~2026-07-10 12:58 UTC|newest]

Thread overview: 9+ 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 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 [this message]
2026-07-09 16:39     ` David Laight

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=2026071019-parkway-captivate-086f@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=Frank.li@oss.nxp.com \
    --cc=andrzej.p@samsung.com \
    --cc=balbi@ti.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox