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 C673913AD0 for ; Mon, 26 Jun 2023 18:13:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34334C433CD; Mon, 26 Jun 2023 18:13:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1687803239; bh=upjKWY3ePmT0+5OTx+e1EdKOzrV8MszSalH+rFu4jbw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ATNnRye1mcF+hvk1lQNWPuPIofNSQZkyCMB499hthWe2sVabIZsGoXXk5SvzCs6/o 4pnQC+X1GoD68cB+zeCBD6KAAjKT6EUD6X+fNtVXqZ18cv+fpoLJ2eVQ00Jyvj+Awk faSZIwGdCmRXIZ3YFqqk5Zlq+CZhzhuZ3vCk1HVQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dan Carpenter , Sasha Levin Subject: [PATCH 4.14 20/26] usb: gadget: udc: fix NULL dereference in remove() Date: Mon, 26 Jun 2023 20:11:22 +0200 Message-ID: <20230626180734.465097402@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230626180733.699092073@linuxfoundation.org> References: <20230626180733.699092073@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 73413c1211cbd..8849fc3030bd2 100644 --- a/drivers/usb/gadget/udc/amd5536udc_pci.c +++ b/drivers/usb/gadget/udc/amd5536udc_pci.c @@ -175,6 +175,9 @@ static int udc_pci_probe( retval = -ENODEV; goto err_probe; } + + udc = dev; + return 0; err_probe: -- 2.39.2