From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 478F335A393 for ; Thu, 9 Jul 2026 16:39:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783615190; cv=none; b=JCaJSiyxoVLAfyRTpwSoRqZ35kXLPTWkTBP3voGyQE0wBrFsFzjqCTH0qIxzk5wINAizAiNKehOkkCeMPAfU1Az/udPXtw8tmh0VVMdQ0A8CxmIxXwCmlVG3fXZWYIJsBYOXdB7412jCDTpQCbmdk6f18+6aUzA/qDcApm0pWec= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783615190; c=relaxed/simple; bh=vaNwRoIjhye69eveL4rFSb3FVRqGKzDCxkgsIv4QOPU=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mQmRwdesx+JUakkMngTa4/kjH68qEP5/AAGSn3gVsWdkfxrWuYda7uT2ztST2dFJGBQ+ZTcjLl9Pl7MbcB0xFXtJysATt+vqlJJ5QTJB1K/OHBVZGH4rpFWC9ZQk7pTOzkoML1W1PRg1C+U+3wpqof1+QSjMggueRUsevqneVRM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LYRabxUr; arc=none smtp.client-ip=209.85.221.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LYRabxUr" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-470174001a0so89282f8f.0 for ; Thu, 09 Jul 2026 09:39:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783615188; x=1784219988; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=YXX9nNx5eZSBjCWWcOzM36IZ91PUM/Pz7bOwY12g6SQ=; b=LYRabxUrBvMrZFo9MkOr6CJs0T7wAHRGT3VEGB15LZPDj/hcbRp+fSz8l3l6NwUI8B 0n9kamORAVEdHvzwpIJhdtyHoHGtTdCkHG8v2SwiBQ+aY3jFmoJOdc8RcUZXA2PJ1ux3 LdsHN1O9EPzbG+qd339KYLmb1pPeJH5+frWDuf2e9jAWSj0b+StmUG6UEZVlGTjvAXWI wJbQ/67g/lJ1ebSn6Ym18m5aXPfZWoqmKbO8wnqdCLU7UMC/uNPSIoVbOnUi685R8nO6 IJQfQQeIMPCXYVxoKDPEg64usf2haR67Kgr+4gMDPF9R5tAEI+zvNuf57VwpmVnQwXlL te8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783615188; x=1784219988; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=YXX9nNx5eZSBjCWWcOzM36IZ91PUM/Pz7bOwY12g6SQ=; b=Aqqd9s4GwlPbWdwclI5Wr4bALDAHi+qyo/TuAxPjDb4JaKZTDcUdVY4ze9guSz5Mjh UK8jbaxE/pS9Qi0EsU8QvKUenmiP6Rta2tT/S3RsoSuZhGym2CBHNux1Z8WA2a/zqT8u vv8uuJto+Ekiwk4msyFsfKye+4OQSb11+eyjieppp4HmIvJXd6xBMFNG/YGqyk6iEz0z Xwex6Uu2+puWXjStn0TWKWCqMOEjg91CEjOckUIiGxYIlGv3KYt7b3+UZNjNv7nxsHHz p2jAvdF37+dQLzGz9GLhXWz9K9fi6aaKG9+eAc3tuLpkVNaZkWgIn0c6404jsuzQsYbA GgEw== X-Forwarded-Encrypted: i=1; AHgh+RpllUd2LDgUFZzf2wSfpEJENUagwybVDKvmhx1fsR08Y9pD4VGxO7+1mIrRAnu2Q8djkhLGMoJJR/X1sfQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwV+MzcDTkuBRCtqiOzKVPkdBl0Sc1NIee9yJhwOq5GvYzM+LTj +P2NWk1YGwpXyIELoV9Gf9RQ0XDk6FS+49xq8cKvE9rDshxUWqZQOoB1 X-Gm-Gg: AfdE7cn4yUGL3utm2hu2rugRcQtg1tjhbfvOoCMjkAFRXfI3SYw96ssEDQlOk80aCCX UEpy0YzfAFSVLcqxDPdTCKCkY5L0J4hXCTGC95aT48DGtW5kxr8co6nm2fQK9PNLA3kpr7bUn3Y +x+Y3+0vxpE8CtbupJbR1aL2UG+y2jg06RXRUGHpyDrK1JbZalPRBt4lw8+p8S4FhbRTqp7ttOC OHXVL/Z6HqttkY40KyT3yGDqkA1NnBYcbtqb9lZdj/26TJapidhQxh97cSL78312qKULwHLl4O5 IaXcFIOdnEzM6KbJD6garMc74INGvYMZtez5r68/h6KOpxx+Fc5xAYXGieAJ9dYxuG9zJTKN32X hEAvEpo7pxwaEe9LPYe4M5Igw5nODfgRyIPBJfJpF9F2+Rr9WWXWt5PWW6NO+Vk9NsFhTi6mqNg Iu1/zvAS8woVu0U0YleysYlftVUaoW9QySFVXmQnpKUZ9xBg== X-Received: by 2002:a5d:588a:0:b0:47d:ee7d:c125 with SMTP id ffacd0b85a97d-47df07faccemr8178775f8f.40.1783615187636; Thu, 09 Jul 2026 09:39:47 -0700 (PDT) Received: from pumpkin (host-92-21-50-228.as13285.net. [92.21.50.228]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47a9e4d83bdsm52545593f8f.13.2026.07.09.09.39.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2026 09:39:47 -0700 (PDT) Date: Thu, 9 Jul 2026 17:39:45 +0100 From: David Laight To: Frank Li Cc: Greg KH , Xu Yang , 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() Message-ID: <20260709173945.268a9917@pumpkin> In-Reply-To: References: <20260625113154.1954813-1-xu.yang_2@oss.nxp.com> <2026070831-peso-aluminum-df0c@gregkh> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Wed, 8 Jul 2026 15:54:03 -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: =20 > > > From: Xu Yang > > > > > > kstrndup() returns NULL on allocation failure. The condition was > > > checking 'if (tmp)' to detect failure, but this is inverted =E2=80=94= 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 > > > --- > > > 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/us= b/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 =3D kstrndup(page, len, GFP_KERNEL); \ > > > - if (tmp) { \ > > > + if (!tmp) { \ > > > ret =3D -ENOMEM; \ > > > goto end; \ > > > } \ > > > -- > > > 2.34.1 > > > > > > =20 > > > > 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? =20 >=20 > 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 >=20 > Frank >=20 > > > > thanks, > > > > greg k-h > > =20 >=20