From patchwork Fri Oct 25 07:07:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Han X-Patchwork-Id: 13850142 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 551F8D11704 for ; Fri, 25 Oct 2024 07:08:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id: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=irTYzw9fExQFZGPQxfydVJgd5rZ15MXr67V4ti7diPs=; b=NEhWoPFT5Qq4PT se741+/RoDznNP5L5vvL17pgN+leL48tNc2Lg9bSul4oJff2sFNGLN6/k876a64XRmCLJZHPQY+jX 3uNACi9Eu5uA+BcNH4BWvVCjimuvpdJxGYzGiB5mVMzoPhPZ7Hb7dpBEtGOvOi1ANgRz1P4Y0bJuC W/hWJWiy2iqqg21BFNB0n8E41iOcUpBCC2LpfQ1A60KDBUuEO0U15KuzDEb+FVqaYX8aOSpvUdh+Y MaFSYfNeU9GgLQq4shLM9sFBjeLSmP5jVBjDcTwQL9Jes6Z8/ubSnfTZ/mrPLtIRK4h0j3JwPly8e 790I6zAG8LQ4fysd4puw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t4EQU-00000002lTe-3XMR; Fri, 25 Oct 2024 07:08:02 +0000 Received: from ssh248.corpemail.net ([210.51.61.248]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t4EQR-00000002lSz-0cjY for linux-phy@lists.infradead.org; Fri, 25 Oct 2024 07:08:00 +0000 Received: from ssh248.corpemail.net by ssh248.corpemail.net ((D)) with ASMTP (SSL) id VHG00144; Fri, 25 Oct 2024 15:07:44 +0800 Received: from jtjnmail201607.home.langchao.com (10.100.2.7) by jtjnmail201622.home.langchao.com (10.100.2.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 25 Oct 2024 15:07:46 +0800 Received: from localhost.localdomain (10.94.19.204) 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; Fri, 25 Oct 2024 15:07:46 +0800 From: Charles Han To: , , , CC: , , , , Charles Han Subject: [PATCH] phy: realtek: usb: fix NULL deref in rtk_usb3phy_probe Date: Fri, 25 Oct 2024 15:07:44 +0800 Message-ID: <20241025070744.149070-1-hanchunchao@inspur.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Originating-IP: [10.94.19.204] X-ClientProxiedBy: Jtjnmail201614.home.langchao.com (10.100.2.14) To jtjnmail201607.home.langchao.com (10.100.2.7) tUid: 2024102515074420f08e701335df5e366a5b17e873c955 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-20241025_000759_474091_285C99D9 X-CRM114-Status: UNSURE ( 7.11 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org In rtk_usb3phy_probe() devm_kzalloc() may return NULL but this returned value is not checked. Fixes: adda6e82a7de ("phy: realtek: usb: Add driver for the Realtek SoC USB 3.0 PHY") Signed-off-by: Charles Han --- drivers/phy/realtek/phy-rtk-usb3.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/phy/realtek/phy-rtk-usb3.c b/drivers/phy/realtek/phy-rtk-usb3.c index 0cef29a7ddd9..cce453686db2 100644 --- a/drivers/phy/realtek/phy-rtk-usb3.c +++ b/drivers/phy/realtek/phy-rtk-usb3.c @@ -577,6 +577,8 @@ static int rtk_usb3phy_probe(struct platform_device *pdev) rtk_phy->dev = &pdev->dev; rtk_phy->phy_cfg = devm_kzalloc(dev, sizeof(*phy_cfg), GFP_KERNEL); + if (!rtk_phy->phy_cfg) + return -ENOMEM; memcpy(rtk_phy->phy_cfg, phy_cfg, sizeof(*phy_cfg));