Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp4835523ioo; Tue, 31 May 2022 12:49:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxg45N5omfZNV5006xvzXSPvtfAVlboEinE3pCJuHRWRf5JsKVI/LJ5S1NECfIMPIAxqtD3 X-Received: by 2002:a17:907:7f14:b0:6ff:2013:3e98 with SMTP id qf20-20020a1709077f1400b006ff20133e98mr23732898ejc.73.1654026559916; Tue, 31 May 2022 12:49:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654026559; cv=none; d=google.com; s=arc-20160816; b=tCCqHoCNdRlynAmoBnXM+vvjiJl0VN5UyvR+mfvBAr0kzZm9yBaxLTo8Goid4gXiAE 2SKBXT4ZysurzboIMTHLDvZyAXWsEYNzaK8ltc3D4/IdUwI6VgnUJXG1k247lCKVNvl0 D/6BCB+U9hjP7zGsMkxYe513A3l/Yt/QoXinOe+8/uJDzpWjxERLS8I7HQt6d47ulmCY /jPbWGSfVmAQDhhqlueAVYGzoT6gY5yNzJx5Y5Gh/5WBKcDcKJyndXmF1N4LvmFejewY MeDwyvJ6TtoUVU4dnYV8p9GTkGvvw0jt4YTfLh54PlQUcKKSNFHb+QNXs+zmDxfXzc7s Hpsg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VHGmB6rJNA3PzlFx11Dw2jcPGOqAtLttypYeYtE4epA=; b=g4Wcs0li4A8PJUM7AAbAEAyN9XmcVHD+WXfD/PP0ctbJSUF39ECEG2Vl4r4V5nQZl+ 13UQtOTBGFU4f0xsbY8Uw/jklklIlXs0K5S9xXOMZid1UVGBBfh7848gpbK3lrcUuPUp aeIIpYO+vlGV3ncfOYY2nqFZ/c01dR9QakMTfr02tqA1Ztof5gBzsmx2Hg+NCYNt/d5y ZWT6Nxf8jxzUln7GY7hGuKMw7vR62m3WriHJVtlsOF3VjFxkH9Sv3sshyg2ymKDliesG ank9tj/VFjZlIE8svOn/cWUIFKTLuA1T75r/SGfUOXsHI4LuaVs4Y/9beFmOKqU75vNp mNmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qc8NCHhF; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p27-20020a056402501b00b0042d8ee7ada0si10901126eda.607.2022.05.31.12.48.54; Tue, 31 May 2022 12:49:19 -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=@kernel.org header.s=k20201202 header.b=qc8NCHhF; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236187AbiE3Obo (ORCPT + 99 others); Mon, 30 May 2022 10:31:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242067AbiE3OSW (ORCPT ); Mon, 30 May 2022 10:18:22 -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 C83FAA0D19; Mon, 30 May 2022 06:49:04 -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 495C060FEE; Mon, 30 May 2022 13:49:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 639FEC3411A; Mon, 30 May 2022 13:49:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653918541; bh=Ecj1LCmySlw3UXUM/IrotAjv0vdchoIgerpHEdcPD6k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qc8NCHhFTGq+L791/aIi7LvbA3kXa4iwlB3MJd14VdhSufAPakoT97dFv9rhXJYHr C9NH6/4NnV+8nYV/IgW/o87pjWTGUYzTywd7Eczcf6PeNrPP/ZVFFUlOGD0oq14oSc AaX5z71WfDLSaxAPox7fnie6cLwnGoAV/gBM9Is5DjKJANa7FXs96lYiCs6zdmJlb+ rAdaZNIQFmQrLd0wCiowaz74ojpcFD5VHlMHa75NKgCnhlcwbxrvsmy4/k90RCbD9S LC02h+Af2EXqkGD2EyUxTA5FXOioxVrnvhocEQyFFQS3p+auhRSv79H8VU6VvDmbPv LJ+1SUHgBslGA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Fabio Estevam , Andrew Lunn , Jakub Kicinski , Sasha Levin , hkallweit1@gmail.com, davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 48/55] net: phy: micrel: Allow probing without .driver_data Date: Mon, 30 May 2022 09:46:54 -0400 Message-Id: <20220530134701.1935933-48-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220530134701.1935933-1-sashal@kernel.org> References: <20220530134701.1935933-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 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