From patchwork Sun Sep 29 03:14:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Han X-Patchwork-Id: 13814807 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1455BCF6493 for ; Sun, 29 Sep 2024 03:16:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:CC:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=aYUGCUHQ0lqm/KtObXxJzflrJ1/TXjsWs7nO0A6h7j0=; b=0pCWs/b8k8j/VIMEY29UyciLQo d3S1FP4s7TamhFRUznJ3HQi0rgWWKFhE8D0Pgcn5U8ZOvPm9oTQjBk2Ai/7JXW8LNGVk9gfV/CJh5 dXbf/ppyK6z05kGRTMyU8l7WUpFImSnmE0PLKf2gyzSz5CLEFP5CFcmfGyX+yN/cyfNNIXG/f9/d7 R9JQUuW3DhXICXqW80UG5MvE6mF5l5a1sSLHnId0FWEEdYLrYLGXY1IKFIhoBfMR+Afq8jque8Z2P b5meX8n1l69RT8EQO2q4ZGm9LZ2S5PjcU/8bEGjD18ijhvwG1c2bPfOxTWiNENoeyqkSX5yJkrfxv R+oAFoIw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sukPb-0000000E22b-0w43; Sun, 29 Sep 2024 03:15:55 +0000 Received: from unicom145.biz-email.net ([210.51.26.145]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sukOL-0000000E1jA-284N for linux-arm-kernel@lists.infradead.org; Sun, 29 Sep 2024 03:14:39 +0000 Received: from unicom145.biz-email.net by unicom145.biz-email.net ((D)) with ASMTP (SSL) id ZCR00029; Sun, 29 Sep 2024 11:14:29 +0800 Received: from jtjnmail201607.home.langchao.com (10.100.2.7) by Jtjnmail201615.home.langchao.com (10.100.2.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 29 Sep 2024 11:14:28 +0800 Received: from localhost.localdomain (10.94.12.73) by jtjnmail201607.home.langchao.com (10.100.2.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sun, 29 Sep 2024 11:14:28 +0800 From: Charles Han To: , , , CC: , , , , , Charles Han Subject: [PATCH] usb: gadget: Add check devm_kasprintf() returned value Date: Sun, 29 Sep 2024 11:14:23 +0800 Message-ID: <20240929031423.40630-1-hanchunchao@inspur.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Originating-IP: [10.94.12.73] X-ClientProxiedBy: Jtjnmail201615.home.langchao.com (10.100.2.15) To jtjnmail201607.home.langchao.com (10.100.2.7) tUid: 2024929111429f6c7bdcc3ed866349b777aedc9eb0361 X-Abuse-Reports-To: service@corp-email.com Abuse-Reports-To: service@corp-email.com X-Complaints-To: service@corp-email.com X-Report-Abuse-To: service@corp-email.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240928_201437_871327_378F60CA X-CRM114-Status: UNSURE ( 7.37 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org devm_kasprintf() can return a NULL pointer on failure but this returned value in ast_vhub_init_dev() is not checked. Fixes: 7ecca2a4080c ("usb/gadget: Add driver for Aspeed SoC virtual hub") Signed-off-by: Charles Han --- 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 573109ca5b79..a09f72772e6e 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);