From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 51281C8E5 for ; Mon, 26 Jun 2023 18:37:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2B96C433C9; Mon, 26 Jun 2023 18:37:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1687804631; bh=kOLsJa76zqfPuOfw8I5+PGjN1wLCPIKt8iink4QIXMw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eIJ40PMoh++zelM6JhbVkuP0K8sTqKKyUHuh6WEfa734BGL4aud88ChZsIPZc0uzk VDZlgdHje0Ik27MMwZ9Yd1jRC9wvkm/bdqdCx5Qxv1RCWnZJz5d5+efTlrUUjalpic d26ZePkJyf2j7UyX6uvf1qy3MooTtpi8sYHQyAQU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dan Carpenter , Sasha Levin Subject: [PATCH 5.4 49/60] usb: gadget: udc: fix NULL dereference in remove() Date: Mon, 26 Jun 2023 20:12:28 +0200 Message-ID: <20230626180741.589129920@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230626180739.558575012@linuxfoundation.org> References: <20230626180739.558575012@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Dan Carpenter [ Upstream commit 016da9c65fec9f0e78c4909ed9a0f2d567af6775 ] The "udc" pointer was never set in the probe() function so it will lead to a NULL dereference in udc_pci_remove() when we do: usb_del_gadget_udc(&udc->gadget); Signed-off-by: Dan Carpenter Link: https://lore.kernel.org/r/ZG+A/dNpFWAlCChk@kili Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/gadget/udc/amd5536udc_pci.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/gadget/udc/amd5536udc_pci.c b/drivers/usb/gadget/udc/amd5536udc_pci.c index 362284057d307..a3d15c3fb82a9 100644 --- a/drivers/usb/gadget/udc/amd5536udc_pci.c +++ b/drivers/usb/gadget/udc/amd5536udc_pci.c @@ -171,6 +171,9 @@ static int udc_pci_probe( retval = -ENODEV; goto err_probe; } + + udc = dev; + return 0; err_probe: -- 2.39.2