From patchwork Wed Jan 18 11:21:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddharth Vadapalli X-Patchwork-Id: 13106204 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 C94ECC32793 for ; Wed, 18 Jan 2023 11:23:20 +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=lFeyHw27hUB9LReLTVTS9NWhRCNNhBvjaWNAcrbAko0=; b=z5niCyqnxW/QaA PxIb+P3LSPAiNp0AMuhGUCC4CicWvwU8KvyEsLS4NRYmISYJvEnpzCZp5prLwu4W4cUGYYZzeenrV bmKGiEq/vdSEV6MZ7iJ4in85KH3R//juh/DHtp/qM6YNPdg1jNNgkys+h2Q9OAkO1w3nis4zEdjaR AmSQ4FIHjcCXQwfaIEYQajd1y9XsolUfABCwb591Mq9luNwmZ9fL3neMoNBbYHiVzi97m0TUnTOvX 3+66wfNIT9nAUVLy4sVAwQqnjlfBIbBKY1djYNdG6+EN7BRChSvvJ08r91Yn7TwYpGpFe1c8Xu2aU amuw9hWOhXTe1SNwj+aQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pI6W7-000WMB-RV; Wed, 18 Jan 2023 11:22:07 +0000 Received: from lelv0142.ext.ti.com ([198.47.23.249]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pI6W4-000WKh-4r for linux-arm-kernel@lists.infradead.org; Wed, 18 Jan 2023 11:22:05 +0000 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 30IBLfFA056612; Wed, 18 Jan 2023 05:21:41 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1674040901; bh=OAdIBFrrzccwy+esEDLCSN7tQoc5jz5kJ2Q3YeYHXm8=; h=From:To:CC:Subject:Date; b=Rxd3393nnE72F/PHxYTxWbygdyH8Ly8Up2QckHbJWSahTDO4kAkVowC7NyfMioFbB 0OFPUa3bpsg8euDS8Y+jWRQ+EL+f1xL2wGfx0oldUgL9jkJogNQvEdx6pXUUshLE7y o4z2mVDM3S7PE68uacoQH0xi6NCiGTElPAKsZyow= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 30IBLf1e032518 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 18 Jan 2023 05:21:41 -0600 Received: from DFLE108.ent.ti.com (10.64.6.29) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16; Wed, 18 Jan 2023 05:21:41 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16 via Frontend Transport; Wed, 18 Jan 2023 05:21:41 -0600 Received: from uda0492258.dhcp.ti.com (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 30IBLbt9032879; Wed, 18 Jan 2023 05:21:38 -0600 From: Siddharth Vadapalli To: , , , , , , CC: , , , , Subject: [PATCH net-next] net: ethernet: ti: am65-cpsw: Handle -EPROBE_DEFER for Serdes PHY Date: Wed, 18 Jan 2023 16:51:36 +0530 Message-ID: <20230118112136.213061-1-s-vadapalli@ti.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230118_032204_305422_86A43EE4 X-CRM114-Status: GOOD ( 12.87 ) 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 In the am65_cpsw_init_serdes_phy() function, the error handling for the call to the devm_of_phy_get() function misses the case where the return value of devm_of_phy_get() is ERR_PTR(-EPROBE_DEFER). Proceeding without handling this case will result in a crash when the "phy" pointer with this value is dereferenced by phy_init() in am65_cpsw_enable_phy(). Fix this by adding appropriate error handling code. Reported-by: Geert Uytterhoeven Fixes: dab2b265dd23 ("net: ethernet: ti: am65-cpsw: Add support for SERDES configuration") Suggested-by: Geert Uytterhoeven Signed-off-by: Siddharth Vadapalli Reviewed-by: Roger Quadros --- This issue has been reported at: Link: https://lore.kernel.org/r/CAMuHMdWiXu9OJxH4mRnneC3jhqTEcYXek3kbr7svhJ3cnPPwcw@mail.gmail.com/ drivers/net/ethernet/ti/am65-cpsw-nuss.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c index 5cac98284184..c696da89962f 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -1463,6 +1463,8 @@ static int am65_cpsw_init_serdes_phy(struct device *dev, struct device_node *por phy = devm_of_phy_get(dev, port_np, name); if (PTR_ERR(phy) == -ENODEV) return 0; + if (IS_ERR(phy)) + return PTR_ERR(phy); /* Serdes PHY exists. Store it. */ port->slave.serdes_phy = phy;