From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796122113; b=yMh14ozofQztw/SQo/w3pjoz+1wGk+5VdiBAx/E6ojzC+Tx80N0TNMuXueLGrA9acAqO jcSSGLATTBS0EUrzg7dwT69/ORSbNkvW9XQv85SVSjIE3Y36Rn0M9ODiwyBoLY7r6ACFF MXfGWz7V/hHCEoE+0lGWjm+ltDBT8KNqNGUoaesGguHVssyPko0oSf7xdrLC9ogly7sa2 aGM7KdcxWQ5/44Xr44JFxgI7SgkfoeVkPsgJPx8/JQxcys7bSwwVE0EFruDQRWM8qMBVy vN/UvxI9H2rtD7lhGsq0gRdx+WHDLIB4cL1ZJrW2ABmFZm9wlwAndFD68DQcjCbjNRA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796122113; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=eUQSkjhpzgDiYYQRok1NUjZhG4iPsSiLXZZtzROZTt8=; b=JfEBj7OElGYzUJCFbaFLGQAJNHj9yG5/WWJLT8IWqQ4i4mSphex9eaoqmxMvq/CPADb2 57DCcACDOQjl/IUk8/3TQ8XL07U63H4QnMxEm41yOesHoWOi/M/OmrFYFYJWsE1QWkpGM 0+Tmfrc9QcyF9ocoQWolT9/IlM+MyWcdICRIlsWoGY30q0gtiQVg0JPyEVflqOvkJmvX2 8ZdDk9t6/sovBuuivIfyZfH98xI3aM714gG+3LVnEti+AdOkvb0wru75Je//A39T90/gY q+75KJM8Os7Br3WznDmCK7+zfe0b9J0u5pDslkec2Wy1GnDFba5Osh0PLANiNgYc9Dg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FZwH8IOZ; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF4BF606A31A for ; Tue, 1 Dec 2026 10:48:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FZwH8IOZ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36BE81F000C1; Tue, 1 Dec 2026 10:48:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796122113; bh=eUQSkjhpzgDiYYQRok1NUjZhG4iPsSiLXZZtzROZTt8=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=FZwH8IOZOs4UboiFuALEwNHzgL3b7kvb/O6bQR+sJGmSOi4UlaYGO2AvSi8twl0zJ 6okpqGk8nX7lmV2jUMC2+x3sqdaOcKg7EYsQnfRdULiaBWKzxwXymoQZZ3bKJ4E6OK Zi72k1wji7vVVfu9kAT0qzFXB/lkRdvj8oG+U3N92cZtjuN6X7DUWxb9jY6QBb65Fq 4cF3p3vQs1zEGjmgE2n+8eYXpy/3qON31S3u8soh1H9CUJw+l2txXBloPWIsfNU9qr Ne4zhYyQkVsALiI8yFE5S4+cfoyHFjXw6Wm5mFLMWanZwar5vo8AD82BbYtd1fC4DR 3PshKhXxEWvXg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] usb: gadget: fsl_qe_udc: Fix gadget lifetime and probe resource leaks Reply-To: sashiko-reviews@lists.linux.dev To: "Wanhui Fu" Cc: linux-usb@vger.kernel.org In-Reply-To: <20261201103911.3309038-1-fuwh1120@163.com> References: <20261201103911.3309038-1-fuwh1120@163.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 10:48:32 +0000 X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] usb: gadget: fsl_qe_udc: inaccurate Fixes trailer citing d77c1198666d -- commit 64343cbe73c11d8bc05f500bd0f35657cb66b1fd Author: Wanhui Fu > usb: gadget: fsl_qe_udc: Fix gadget lifetime and probe resource leaks > > qe_udc_config() allocates an endpoint parameter block in MURAM. > However, failures in qe_udc_probe() free the controller without > releasing this block. > > Furthermore, usb_add_gadget_udc_release() drops the gadget > reference on registration failure, potentially invoking > qe_udc_release() before probe has finished unwinding. This can > result in a NULL pointer dereference in complete(), use-after-free > and double free. A similar lifetime issue exists on removal. > > Initialize the gadget immediately after qe_udc_config() succeeds > and register it separately using usb_add_gadget(). Release the > initial gadget reference only after the remaining resources have > been cleaned up on probe failure and removal. > > Found it by self-developed static analysis tool. Compile-test > passed. > > Fixes: 3948f0e0c999 ("usb: add Freescale QE/CPM USB peripheral controller= driver") > Fixes: d77c1198666d ("usb: gadget: fsl_qe_udc: convert to new style start= /stop") > Signed-off-by: Wanhui Fu [Severity: Low] Is the second Fixes: tag accurate? Commit d77c1198666d ("usb: gadget: fsl_qe_udc: convert to new style start/stop") only converted the start/stop callbacks and replaced the global udc_controller pointer with a local udc pointer without changing gadget device registration or release lifetime. The premature gadget release on probe failure and removal was introduced wh= en udc-core took over gadget.dev management in commits 0f91349b89f3 ("usb: gadget: convert all users to the new udc infrastructure"), c07d1b63ac3c ("usb: gadget: fsl_qe_udc: let udc-core manage gadget->dev"), and 29e7dbf32967 ("usb: gadget: fsl_qe_udc: don't assign gadget.dev.release directly"). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201103911.3309= 038-1-fuwh1120@163.com?part=3D1