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 2E0DB241667; Tue, 29 Apr 2025 16:53: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=1745945592; cv=none; b=M1q/BdPTJ2fdz25oFPVi1UWEZqw6yOo1USshM8ALeQV5f0tB5EfzqJLLBuQq0WIb2dMhnjPU+g7i8CTYokWGwKA6/+pXxsBh8KWsYy3vQNzNEbGgVhf5id7eezdr9vUh80cILwHRFqV2JFtUirCssKBr67Gn2fIJO/pNL+jn0AI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745945592; c=relaxed/simple; bh=DCpFpP5klCWdmj4hHlRG+a4OwMFvM4dn1isN4y48P44=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U9EUiiNUmhFd5M51wpKBsh5nBgnoMCzRELjE+VSkslRMDH2msh80VnfyxE+1HuCTThwmTn/svObbpDepZNEPnYD5XVYyhGwIoI9VzmXiJ/MXmdxLP/1t8b+8O0OElPpv97nrNt+aCMnshmnkqtVCDdqIUmQlu4yhJ69j1rcCaOg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=iQB/ys//; 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="iQB/ys//" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3C48C4CEE3; Tue, 29 Apr 2025 16:53:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745945592; bh=DCpFpP5klCWdmj4hHlRG+a4OwMFvM4dn1isN4y48P44=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iQB/ys//iJid8nZPBL5WlnUhBkcbQsH3KHRpKy9PHrHqKz8IDxcWkKDqeq4uRz9Ca 15afr+o7Lf9jw2nGsKfK7p80O3Hk175wsddEQ6QCt2TdKst5yviU0oOCk6RijfdA1l vgfEwl/bLH4e0FE02cfYfY3tfATs9PCJ2UXKPjxI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chenyuan Yang , Sasha Levin Subject: [PATCH 5.4 165/179] usb: gadget: aspeed: Add NULL pointer check in ast_vhub_init_dev() Date: Tue, 29 Apr 2025 18:41:46 +0200 Message-ID: <20250429161056.056410339@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250429161049.383278312@linuxfoundation.org> References: <20250429161049.383278312@linuxfoundation.org> User-Agent: quilt/0.68 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.4-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 4008e7a511889..89d7d3b24718d 100644 --- a/drivers/usb/gadget/udc/aspeed-vhub/dev.c +++ b/drivers/usb/gadget/udc/aspeed-vhub/dev.c @@ -542,6 +542,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