From patchwork Mon Oct 28 06:01:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "zhangzekun (A)" X-Patchwork-Id: 13853049 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (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 C450D18EFD2 for ; Mon, 28 Oct 2024 06:06:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730095604; cv=none; b=d4VFnaus0hW4Jx8IsZBbuDVJPVBsem+E+ZQPXmqiDB3QK3hSuxo5tTBIq1g0I2g10DsSm3gcQkZE2GY2a53xW+zwijBXStSJJOOfjtlaZgaw9xbfaQqjgByDeAtIxAEcWtn7xsPyiEg2VRMa8JPjM+PRhUznZPO9Pr69CjfeWt8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730095604; c=relaxed/simple; bh=hjbmCVEgdYw13utb3ARrRH//Pq802INSHmN0uYbN4Cw=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=gOhfvhDjpvbVePGDgEck/teQldxFksmggn/ujZNWt6qVYQha8Ti3JOQEBCDF0P9I4rbeJAQp305QrkeqR8zzNjWU1Xo2jirkNohWrs0ReV5C7oIzx4W5YeGXYfAWIMm0qOU2uptTDLaT49huFhOjgUyAT3uzZxCp50e0Y5j07U0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4XcNCR0zxwz1jw1s; Mon, 28 Oct 2024 14:05:07 +0800 (CST) Received: from kwepemf500003.china.huawei.com (unknown [7.202.181.241]) by mail.maildlp.com (Postfix) with ESMTPS id 4333314022D; Mon, 28 Oct 2024 14:06:36 +0800 (CST) Received: from huawei.com (10.175.112.208) by kwepemf500003.china.huawei.com (7.202.181.241) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 28 Oct 2024 14:06:35 +0800 From: Zhang Zekun To: , , , CC: , , Subject: [PATCH] engine: ti: Fix potential NULL pointer dereference Date: Mon, 28 Oct 2024 14:01:40 +0800 Message-ID: <20241028060140.5232-1-zhangzekun11@huawei.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemf500003.china.huawei.com (7.202.181.241) devm_kasprintf() could failed and return a NULL pointer, which will then be used in the later code. Add check to prevent the potential NULL pointer dereference. Fixes: 25dcb5dd7b7c ("dmaengine: ti: New driver for K3 UDMA") Signed-off-by: Zhang Zekun --- drivers/dma/ti/k3-udma.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c index 406ee199c2ac..fdaea8f72a9c 100644 --- a/drivers/dma/ti/k3-udma.c +++ b/drivers/dma/ti/k3-udma.c @@ -5534,6 +5534,8 @@ static int udma_probe(struct platform_device *pdev) uc->config.dir = DMA_MEM_TO_MEM; uc->name = devm_kasprintf(dev, GFP_KERNEL, "%s chan%d", dev_name(dev), i); + if (!uc->name) + return -ENOMEM; vchan_init(&uc->vc, &ud->ddev); /* Use custom vchan completion handling */