Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp592876iog; Mon, 13 Jun 2022 08:46:27 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tBZsMI10TwEbU/p7nscFEmMv/JWTbiyM9Dt+UsnROGmrRuRIQLz9KL5Op7QXS49HdKt9ku X-Received: by 2002:a17:90b:3b92:b0:1e3:16b5:33df with SMTP id pc18-20020a17090b3b9200b001e316b533dfmr435082pjb.198.1655135187529; Mon, 13 Jun 2022 08:46:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655135187; cv=none; d=google.com; s=arc-20160816; b=Tbq5bJD8/AQvgpiYgNRjRQdS/Jju/skwFU/LsD13sElTAVRBrpvgLfzByb/54kbsMF 6yqLbEErI1UEsiBftRjpOaiXWerRO3lXFe3MbqP3YuN2KTWwScDZRgMyZ9g/5gCUxlfE npodMNWfJWqYk6RMhnZ3W3Wpy831ruL/SLFzivK1igw7BpScVpsXem3Udbdjie2PXkh9 XYA73EFslWbRGraSNAjngY7Kk4QxwjkVP5oQj7MDm+9XOf8DHCcpZIVnUkLzQsUGiQ8k LpeWidMTQ+M6nDCSQfyJFjh9UmGG3DSAop+5K7jFM54cYvLwHUCsKzxTWPVIkgD7Gu3v lHeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VHGmB6rJNA3PzlFx11Dw2jcPGOqAtLttypYeYtE4epA=; b=NMRnsq+ipW0EdjJn5n05JbSMp1xm2TZ3UXaMs9dxNJgugYvjgYK8iE3jws8zZtk35o G4ZSw/imW4yKnNEjln4RqYH4TNqHXbTFx4dq/bI5i3brfMaQ5Y1H4EYk5iULt6Wcwdsr u/DtGaX3AJ48k/YTphdmlwu4dnr5xU7UPvJUjac9L61M3pAlDyf4TF1YZu1pkweVXHb2 ag+eSCMw7DnY4i6OaTAq2OQEZUJ0JTcvuCy11f8m3EFIDscdNGWanxF5v+//s9dbI1Yr 9zWvNHKuTDj2+0rm/ozelxN4GZPBbsNncpJaj//reAd2t9rxU7MBYqPtJN8MhFJYSpUP uRvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="VfD/ADgV"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p29-20020a63951d000000b003fe24378d92si9283221pgd.156.2022.06.13.08.46.15; Mon, 13 Jun 2022 08:46:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="VfD/ADgV"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351558AbiFMLEi (ORCPT + 99 others); Mon, 13 Jun 2022 07:04:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350380AbiFMKyv (ORCPT ); Mon, 13 Jun 2022 06:54:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D41DF1EEEC; Mon, 13 Jun 2022 03:31:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 74B6A60FAD; Mon, 13 Jun 2022 10:31:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87780C34114; Mon, 13 Jun 2022 10:31:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655116275; bh=Ecj1LCmySlw3UXUM/IrotAjv0vdchoIgerpHEdcPD6k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VfD/ADgVXbBlxESI5j5EdvXU9U74ddANckM2uCjnd+LF6VwcMk/CJfOywURFoLy4K ukUPTNVCJCxsqxBg/9uw8IOjAQOCxJLpeeeIXmIbA5UI7R+/BqQbLj9JP1eHJll9Yb dUkl0BY4xR3xZjR7dIsZYXDYGPK2cvvdJtVR2XTE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fabio Estevam , Andrew Lunn , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.4 056/411] net: phy: micrel: Allow probing without .driver_data Date: Mon, 13 Jun 2022 12:05:29 +0200 Message-Id: <20220613094930.193456909@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fabio Estevam [ Upstream commit f2ef6f7539c68c6bd6c32323d8845ee102b7c450 ] Currently, if the .probe element is present in the phy_driver structure and the .driver_data is not, a NULL pointer dereference happens. Allow passing .probe without .driver_data by inserting NULL checks for priv->type. Signed-off-by: Fabio Estevam Reviewed-by: Andrew Lunn Link: https://lore.kernel.org/r/20220513114613.762810-1-festevam@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/phy/micrel.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 18cc5e4280e8..721153dcfd15 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -282,7 +282,7 @@ static int kszphy_config_reset(struct phy_device *phydev) } } - if (priv->led_mode >= 0) + if (priv->type && priv->led_mode >= 0) kszphy_setup_led(phydev, priv->type->led_mode_reg, priv->led_mode); return 0; @@ -298,10 +298,10 @@ static int kszphy_config_init(struct phy_device *phydev) type = priv->type; - if (type->has_broadcast_disable) + if (type && type->has_broadcast_disable) kszphy_broadcast_disable(phydev); - if (type->has_nand_tree_disable) + if (type && type->has_nand_tree_disable) kszphy_nand_tree_disable(phydev); return kszphy_config_reset(phydev); @@ -939,7 +939,7 @@ static int kszphy_probe(struct phy_device *phydev) priv->type = type; - if (type->led_mode_reg) { + if (type && type->led_mode_reg) { ret = of_property_read_u32(np, "micrel,led-mode", &priv->led_mode); if (ret) @@ -960,7 +960,8 @@ static int kszphy_probe(struct phy_device *phydev) unsigned long rate = clk_get_rate(clk); bool rmii_ref_clk_sel_25_mhz; - priv->rmii_ref_clk_sel = type->has_rmii_ref_clk_sel; + if (type) + priv->rmii_ref_clk_sel = type->has_rmii_ref_clk_sel; rmii_ref_clk_sel_25_mhz = of_property_read_bool(np, "micrel,rmii-reference-clock-select-25-mhz"); -- 2.35.1