From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 779074CE67E; Wed, 30 Sep 2026 15:34:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790782469; cv=none; b=rNrT942YpEDfARIR/Q0ROX8t96OGftu6I0YguD9CYqEnbV7590zZGWMxUqveDGe+JaUPssMgwH60gjrXUIAqZm4dg6hnxvGTO5blATEZy/yFd/4ZJvmd0j6i/FjeU2XZdPFzb9c+gjf0ufbh+7AhTLhzDTCBeQpd/NvjWcgknY0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790782469; c=relaxed/simple; bh=PgMprE7oJ/jx6N0w9eYEhogd/mwvwc2WfKLd4lAjBGM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RI3WAaRVXHykcAVOZYrvQvQ6nSh5v9heTZbNZKY2eQuRIQLpgWmi62MGI/vbf9SGaWNcJFr1S8RDtpxVX1siuI7kQleRHCeis5GqO+dWNjxyLtF8yTwbVH4bxBe54O6F8Ypi0OUWySBK5bQHvy6pztT3daBjsWRoo+Ql3z3nGMo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=tBghxpqA; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="tBghxpqA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6A1A1F0089A; Wed, 30 Sep 2026 15:34:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790782456; bh=8AXbuc3tzqVXsIz5clMskkrfYTtp4iwmMkBK1NsG+iA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=tBghxpqArPTfYCVM8S0+I9SXrmYkgC7fane7sxLWM1ob1GwD1Iav/9ZWeNIQC5mji SW92KfrVhiPYqLO/GgAE0/AJ+xDCpgdlHh2AdqfzwvL62dH31iKmmm+U8YwEz2pJxF mzcHvAvp9x516Fcl66zocYGZlIXcbZViwoK84FQI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Stepan Ionichev , Sasha Levin Subject: [PATCH 5.10 052/595] usb: gadget: goku_udc: avoid NULL deref of dev->driver in INT_USBRESET log Date: Wed, 30 Sep 2026 17:19:05 +0200 Message-ID: <20260930152348.850388126@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152347.700140858@linuxfoundation.org> References: <20260930152347.700140858@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stepan Ionichev [ Upstream commit 5bf5e3fba9bc7dfd69701521dbe9809f8ccbdb02 ] goku_irq() handles a number of bus events under a single ep0 path. It already guards the gadget driver suspend/resume callbacks against a NULL ->driver: if (dev->gadget.speed != USB_SPEED_UNKNOWN && dev->driver && dev->driver->resume) { spin_unlock(&dev->lock); dev->driver->resume(&dev->gadget); ... } but the very next branch unconditionally dereferences dev->driver when an INT_USBRESET arrives: if (stat & INT_USBRESET) { ACK(INT_USBRESET); INFO(dev, "USB reset done, gadget %s\n", dev->driver->driver.name); } If the controller raises INT_USBRESET before any gadget driver has been bound (or after one has been unbound), dev->driver is NULL and the printk dereferences NULL. smatch flags the inconsistency: drivers/usb/gadget/udc/goku_udc.c:1618 goku_irq() error: we previously assumed 'dev->driver' could be null (see line 1607) Fall back to a placeholder when the gadget driver is not bound. No functional change while a gadget driver is bound. Signed-off-by: Stepan Ionichev Link: https://patch.msgid.link/20260509110636.19762-1-sozdayvek@gmail.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/gadget/udc/goku_udc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/udc/goku_udc.c b/drivers/usb/gadget/udc/goku_udc.c index 3e1267d38774f..b9c4adb767efa 100644 --- a/drivers/usb/gadget/udc/goku_udc.c +++ b/drivers/usb/gadget/udc/goku_udc.c @@ -1615,7 +1615,8 @@ static irqreturn_t goku_irq(int irq, void *_dev) if (stat & INT_USBRESET) { /* hub reset done */ ACK(INT_USBRESET); INFO(dev, "USB reset done, gadget %s\n", - dev->driver->driver.name); + dev->driver ? dev->driver->driver.name : + ""); } // and INT_ERR on some endpoint's crc/bitstuff/... problem } -- 2.53.0