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 550E1253334; Tue, 29 Apr 2025 18:16:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745950572; cv=none; b=CBhyo1PKOGfU80ltgLq42Di8UbfMQTJ42yRxh2UL+BNIUBO34KZKdb1BmY2v4HjzWRfZKyRTuMtWONoJ56GAmpdQEiJCBIffOPGsXtgBqWJJlbYF0AppgBtf/X9IncMkAP0USSltDKAxzFZfOF6T0CFnTR+ztFBUAEtEJnydjxs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745950572; c=relaxed/simple; bh=+wFJzEKjIXvxZDI6XLS/u7S7rx3n906v5oHXT2yOR90=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qew+hVgyVdiA0Tb51GSXo02ViIVnGyLT38kxYDL+NGqhmqeQtHhCcIC5QlGycWm96xSrO19Tk9egqSVccgrVisr7fJQJk+780iiJ4mxeCdFzCCUixlfuxNRljUx/cM6MnoAFanTeu3+GFfxBx7Y9ItJXKCCWbRRmHs9O+Ss1ud8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=NeF7tvwF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="NeF7tvwF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B65B5C4CEE3; Tue, 29 Apr 2025 18:16:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745950572; bh=+wFJzEKjIXvxZDI6XLS/u7S7rx3n906v5oHXT2yOR90=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NeF7tvwF5WqJXNRk82VQacDfWP8n8sRLxF4Rw3ohLntaaFrFkKrffRSb+4idbIcdk q9/NtrI6DMu5leUoklVPNMr0B/9eiZwpBpelR6NwV6r6zlGVY2yAASH9Lzo7skBwF3 mms1NcR1xfCuYpu7kB5nlCKrw9kiZxkFgOvgQOI0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chenyuan Yang , Sasha Levin Subject: [PATCH 6.6 138/204] usb: gadget: aspeed: Add NULL pointer check in ast_vhub_init_dev() Date: Tue, 29 Apr 2025 18:43:46 +0200 Message-ID: <20250429161105.079355880@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250429161059.396852607@linuxfoundation.org> References: <20250429161059.396852607@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chenyuan Yang [ Upstream commit 8c75f3e6a433d92084ad4e78b029ae680865420f ] The variable d->name, returned by devm_kasprintf(), could be NULL. A pointer check is added to prevent potential NULL pointer dereference. This is similar to the fix in commit 3027e7b15b02 ("ice: Fix some null pointer dereference issues in ice_ptp.c"). This issue is found by our static analysis tool Signed-off-by: Chenyuan Yang Link: https://lore.kernel.org/r/20250311012705.1233829-1-chenyuan0y@gmail.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/gadget/udc/aspeed-vhub/dev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/gadget/udc/aspeed-vhub/dev.c b/drivers/usb/gadget/udc/aspeed-vhub/dev.c index 573109ca5b799..a09f72772e6e9 100644 --- a/drivers/usb/gadget/udc/aspeed-vhub/dev.c +++ b/drivers/usb/gadget/udc/aspeed-vhub/dev.c @@ -548,6 +548,9 @@ int ast_vhub_init_dev(struct ast_vhub *vhub, unsigned int idx) d->vhub = vhub; d->index = idx; d->name = devm_kasprintf(parent, GFP_KERNEL, "port%d", idx+1); + if (!d->name) + return -ENOMEM; + d->regs = vhub->regs + 0x100 + 0x10 * idx; ast_vhub_init_ep0(vhub, &d->ep0, d); -- 2.39.5