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: 831504 Received: from unicom145.biz-email.net (unicom145.biz-email.net [210.51.26.145]) (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 A7AE48BE7; Sun, 29 Sep 2024 03:14:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.51.26.145 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727579678; cv=none; b=JQe/amU+/lJgJ3E+XBfRAwHsuTYyL4XqqkjN/kAyOIIC1jnCK+KqsAkBPNDPV+rSQSoGiQZ6rqcfhpgzs7tjSHGX9jQx6gyrAiPhNvOzLe7fsM8MX+ddBfuVyx8+SjZICiQ0EGe3sOpTBp7HXMk4dCPYJ2I1mdJb156Uz04tXR0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727579678; c=relaxed/simple; bh=CGo9bbiBfmNWiT9D3YSVKkYQEe5nMMGgBnSNoR0HmvY=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=ltyLUD8le22emQHxn1sbUFiHQn1p6/EH1oBw9ffBOFXY/u+bqMXfVJ1beFfQhKsg4gMVWui1vLppyLoohF2l3ozjqYIdWMKb5n7EDdFIdZJnU3ETQxSxdGp1wi8uj12RUhCsH5VnnpqzdkQ/V7e7KL0rv54o0dQMx2vuiTEb+Gk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=inspur.com; spf=pass smtp.mailfrom=inspur.com; arc=none smtp.client-ip=210.51.26.145 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=inspur.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=inspur.com 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 Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 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);