From patchwork Wed May 4 14:31:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 12838005 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37A3DC433EF for ; Wed, 4 May 2022 14:31:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351344AbiEDOfF (ORCPT ); Wed, 4 May 2022 10:35:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351342AbiEDOfE (ORCPT ); Wed, 4 May 2022 10:35:04 -0400 Received: from mail-oa1-x35.google.com (mail-oa1-x35.google.com [IPv6:2001:4860:4864:20::35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6512F1FA73; Wed, 4 May 2022 07:31:28 -0700 (PDT) Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-e93bbb54f9so1321531fac.12; Wed, 04 May 2022 07:31:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=TkR4+Ak42lKAVTpIpmlEu7xaOxXFRRFm8b0SVx8aIK8=; b=d2zsqe+LjRZ0/q16f0uNPNcEBQsGPHyHl9A0iFGxVxcMbgkkt4Xa3wd0mjcQRXY3Zf I8DvLS/pYwPDXnZLSVXq2pUSf+2Gay7fwp6RWUyAdDligYkS5Gi/9UC3kMs0P1vy62hh L4sNqfBh4j7Aytfg/zxgOgKEEFiPFovy/WDTdFiW+X3OQlWdiX4JYzDW5GzyEHM+Cn6A KHzBPVZiavamj7r4LwMvWrVUEEymhn2KYE2VW33XsojyWNspLO/MTSUfg3fGjZ7iu6Jo O8X5JJiSHlcAbYlzQuHpJdYP9dQ3Uq5V6QqhJqvZhzXJRA9u8vh7dKIO90bDfXclKfD2 vkTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=TkR4+Ak42lKAVTpIpmlEu7xaOxXFRRFm8b0SVx8aIK8=; b=CnoHycRPT6QSdt+AJ7aVKwh96B4AqPVe8HzwTPLDtBZjDHq1fyp3YCUCAqHefCCh7b mD4vEWS+cbZ6Ui2s4pCyNIhVlY6SO03naK1JzEOjllGHvQ7NxPHlR1bsmGPXt4sEUc8r /I5DLEnv/wnMeurLC/QdUOXf+umXS/JY/WXnZM58Oz2WxWJBTz6HlhdQwXKQo9ZIeRAY mLfpCljY8jSMD5hglqemkx9CS1YirkppY14VmD5ETYAkzQaj5qsJLtGtIimjos+7EsCb bByOQxdwTvMg9hHpGUK+ayeJMyQIs3tdXXHaRXb/OSaGicvZ7m4TCocMNXwqQ81gSz7b zIug== X-Gm-Message-State: AOAM532cLxZwVq846EvP95vRcJmwyMjFJX7omWcqQ7l38yeGgEWcaklk hQ8qqCaKtMyAcqvCbuK4LwU= X-Google-Smtp-Source: ABdhPJwVA7TMiQ/jxm7yXoFyx+nQCDbG+YJAW/Hdf84gmBHEKuw2CSOZUJoDpy3jnAbBLJiHIXgvWw== X-Received: by 2002:a05:6870:618e:b0:e5:c2f3:e009 with SMTP id a14-20020a056870618e00b000e5c2f3e009mr3871331oah.10.1651674687522; Wed, 04 May 2022 07:31:27 -0700 (PDT) Received: from localhost.localdomain ([2804:14c:485:4b69:6ef3:840d:df28:4651]) by smtp.gmail.com with ESMTPSA id m9-20020a4ad509000000b0035eb4e5a6dasm6018832oos.48.2022.05.04.07.31.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 May 2022 07:31:27 -0700 (PDT) From: Fabio Estevam To: kuba@kernel.org Cc: davem@davemloft.net, andrew@lunn.ch, claudiu.beznea@microchip.com, netdev@vger.kernel.org, o.rempel@pengutronix.de, linux@armlinux.org.uk, Fabio Estevam , stable@vger.kernel.org Subject: [PATCH net v2 1/2] net: phy: micrel: Do not use kszphy_suspend/resume for KSZ8061 Date: Wed, 4 May 2022 11:31:03 -0300 Message-Id: <20220504143104.1286960-1-festevam@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Fabio Estevam Since commit f1131b9c23fb ("net: phy: micrel: use kszphy_suspend()/kszphy_resume for irq aware devices") the following NULL pointer dereference is observed on a board with KSZ8061: # udhcpc -i eth0 udhcpc: started, v1.35.0 8<--- cut here --- Unable to handle kernel NULL pointer dereference at virtual address 00000008 pgd = f73cef4e [00000008] *pgd=00000000 Internal error: Oops: 5 [#1] SMP ARM Modules linked in: CPU: 0 PID: 196 Comm: ifconfig Not tainted 5.15.37-dirty #94 Hardware name: Freescale i.MX6 SoloX (Device Tree) PC is at kszphy_config_reset+0x10/0x114 LR is at kszphy_resume+0x24/0x64 ... The KSZ8061 phy_driver structure does not have the .probe/..driver_data fields, which means that priv is not allocated. This causes the NULL pointer dereference inside kszphy_config_reset(). Fix the problem by using the generic suspend/resume functions as before. Another alternative would be to provide the .probe and .driver_data information into the structure, but to be on the safe side, let's just restore Ethernet functionality by using the generic suspend/resume. Cc: stable@vger.kernel.org Fixes: f1131b9c23fb ("net: phy: micrel: use kszphy_suspend()/kszphy_resume for irq aware devices") Signed-off-by: Fabio Estevam Reviewed-by: Andrew Lunn --- Changes since v1: - Explained why enphy_suspend/resume solution is preferred (Andrew). drivers/net/phy/micrel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 685a0ab5453c..11cd073630e5 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -3021,8 +3021,8 @@ static struct phy_driver ksphy_driver[] = { .config_init = ksz8061_config_init, .config_intr = kszphy_config_intr, .handle_interrupt = kszphy_handle_interrupt, - .suspend = kszphy_suspend, - .resume = kszphy_resume, + .suspend = genphy_suspend, + .resume = genphy_resume, }, { .phy_id = PHY_ID_KSZ9021, .phy_id_mask = 0x000ffffe, From patchwork Wed May 4 14:31:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 12838006 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7717C433FE for ; Wed, 4 May 2022 14:31:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351351AbiEDOfJ (ORCPT ); Wed, 4 May 2022 10:35:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351347AbiEDOfG (ORCPT ); Wed, 4 May 2022 10:35:06 -0400 Received: from mail-oa1-x35.google.com (mail-oa1-x35.google.com [IPv6:2001:4860:4864:20::35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F7F540A39; Wed, 4 May 2022 07:31:31 -0700 (PDT) Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-e93bbb54f9so1321531fac.12; Wed, 04 May 2022 07:31:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mR7qVUfY5UjZOEcxyx4x5ViEVp0uC0ZkWAsTwVzhVD0=; b=M6uxTD4Ut2Gn0n+p+mO/qkPMcYQ5HveKQrHNVxJYYEzNZkCXif/8QzKLzhbGcwYMnU t0Oc3ar/Jtop0kxJPJi3KmQhDXLpKGlhNF1PKt7w7w4P8m6m+jfPucdUriQQdw7wi9Bl l34TXiMvC511gYXaYNNPzGJmfxDJblFZXvJ/ioCeulZFRwi76XNqyEMrs2wD5s3fYd4S 6zfaEXEuK2PCvSKs4R77mqx+Z1fRyOGXd/bvXdBWVuLr47SXIK7D/5iZWLH9KRHeffXc tmcY50wl/7vgWTom1JBwhGhUXcAkxY0sD0/Mr81Gc1l7LJnumFS9VNOpYXCEV3oQjZYr s5Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mR7qVUfY5UjZOEcxyx4x5ViEVp0uC0ZkWAsTwVzhVD0=; b=TYtG/RohLRcx+X0IcN8yB+NQGAZLCI9KblSTLpnDxByHsS8gRKObLVbK2zyP6TDiDi 81r4hWSDxEN1AsXaolVe/rhiO6vlgz+V3yb550uCzCxDlmQ7SKe61Zws0Cc2c0cq6jkh AN1W2skZsxnigW+1DG4dd4cAZGEQc7MlM2uDdbU7EaMbezd5ZI3BKsn0JfnjiSeKRT60 IctBOO71dKzGWU6D0+DhYq9D/F3COZOuKMpXwRXHslA5bJz6QQssOvZmJX+X15yE4wS3 0L7xQYAuryNiyP9TwiMwGwBAptkjStN+6mxU5en1jWlsyFJUCLJuswVt/lRmTtvIsdie ZpBA== X-Gm-Message-State: AOAM531CySYW9s+D2zH647c7PR5gfV+c15WleOmA147XKNKyYPyVHuRo 0reaMa1nfVC4k0C2thNJBZo= X-Google-Smtp-Source: ABdhPJzmU6cDgEmnlcwzS0PHeU93YvCjTHg61HiF2Ay4p+5NaThOcIz6V73agA43KtkepBmLhrRO5g== X-Received: by 2002:a05:6870:340e:b0:ec:c40f:e630 with SMTP id g14-20020a056870340e00b000ecc40fe630mr3736963oah.144.1651674690955; Wed, 04 May 2022 07:31:30 -0700 (PDT) Received: from localhost.localdomain ([2804:14c:485:4b69:6ef3:840d:df28:4651]) by smtp.gmail.com with ESMTPSA id m9-20020a4ad509000000b0035eb4e5a6dasm6018832oos.48.2022.05.04.07.31.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 May 2022 07:31:30 -0700 (PDT) From: Fabio Estevam To: kuba@kernel.org Cc: davem@davemloft.net, andrew@lunn.ch, claudiu.beznea@microchip.com, netdev@vger.kernel.org, o.rempel@pengutronix.de, linux@armlinux.org.uk, Fabio Estevam , stable@vger.kernel.org Subject: [PATCH net v2 2/2] net: phy: micrel: Pass .probe for KS8737 Date: Wed, 4 May 2022 11:31:04 -0300 Message-Id: <20220504143104.1286960-2-festevam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220504143104.1286960-1-festevam@gmail.com> References: <20220504143104.1286960-1-festevam@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Fabio Estevam Since commit f1131b9c23fb ("net: phy: micrel: use kszphy_suspend()/kszphy_resume for irq aware devices") the kszphy_suspend/ resume hooks are used. These functions require the probe function to be called so that priv can be allocated. Otherwise, a NULL pointer dereference happens inside kszphy_config_reset(). Cc: stable@vger.kernel.org Fixes: f1131b9c23fb ("net: phy: micrel: use kszphy_suspend()/kszphy_resume for irq aware devices") Reported-by: Andrew Lunn Signed-off-by: Fabio Estevam Reviewed-by: Andrew Lunn --- Changes since v1: - Newly introduced. This was noticed by Andrew. drivers/net/phy/micrel.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 11cd073630e5..a06661c07ca8 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -2896,6 +2896,7 @@ static struct phy_driver ksphy_driver[] = { .name = "Micrel KS8737", /* PHY_BASIC_FEATURES */ .driver_data = &ks8737_type, + .probe = kszphy_probe, .config_init = kszphy_config_init, .config_intr = kszphy_config_intr, .handle_interrupt = kszphy_handle_interrupt,