Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp3244466imc; Wed, 13 Mar 2019 12:34:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqz1/egzAFEjvfCugColmwwIG1GVsINz24eZCx0e9L3OUm4G3bNef7XaX2imExgG4oZA9pP7 X-Received: by 2002:a17:902:168:: with SMTP id 95mr25001695plb.212.1552505667592; Wed, 13 Mar 2019 12:34:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552505667; cv=none; d=google.com; s=arc-20160816; b=yY8YCvavrmUgQ+DAU0khfwYv5DI6tA5DBA3Y1TP52a0i+lcOgzh6nuxBsb84Dh0oAE B+mc3Cg0QStUG98LXa0WG6nl8kczgF4FM8mvjgbngEMhYsrr+RVj5VX+x5zghRBemzt9 UtRZgFzvx9WxcsDFGCoWhD934lCnRJ0kcfnzrb2k/mE2NPT+VpSWuJWt2TH+edbbpDMb k/VKo4wj6nXzaDzwsZvwj2bate0dvF2s9fIhnYkmou0ryODL5jUrYI5S+uBNL7nwy2Ro bLG6E/LBvwEWZ35977LHoxq0lY+4DUSatpfxNWJb59kqakL/OYW4pro1IZX5/Mjl1+DD EWLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2bpu95R7tdBwbFow6cJVuZHZKf6pgo9r9HZjUNPPEbA=; b=MVhj4pm11n2S+0H4rnphNz/1w3QhHVLO4t7UP4cO4IxsqsA40vgJ2RC0/WSD6vkfmd RIGdmXT+FjYHK18J/nsoBegSbjl1SFppynY7FY03RB5CBkGJlRHCGgXhimQyf5R4l93/ iNWBvQ1bfeo5+gsqTv8bTQ7CNPXEnpDQ0JbxBsY9yEcvmPfp4AXL54tExvI281Iwb+12 g2SO0lKKslDe+T8tL8VUUYjB8Y8Kd7BN4Rx5CZfny8+UukN2Kl+rgEo0V8Q05Fu8ooO5 D/tdygec+6QIbmP7SBZh1xPtzBpSrwpmNPfpj3JvnMloYVZudAJk/a+DcPUqHJ/24Hab 31Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=us+n4Crz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cy1si12450621plb.429.2019.03.13.12.34.11; Wed, 13 Mar 2019 12:34:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=us+n4Crz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727623AbfCMTdJ (ORCPT + 99 others); Wed, 13 Mar 2019 15:33:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:41550 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727260AbfCMTK6 (ORCPT ); Wed, 13 Mar 2019 15:10:58 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DAFB62184C; Wed, 13 Mar 2019 19:10:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552504257; bh=ognpR68lZ0ABQFK+IlI98eA9rIlTa1PHRDdPUtu5sAs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=us+n4Crz1YjQdEUSlhUu1v6RgFLR++vw6Mue7n7GXgPVhYRAmXinceGrjjiD1UxH+ kvmrJWYsLA/I68X2dhLXCjtUExU5IprKvLAM8UA6RzTplveZx3BzAjdM+1AmxQaEbM umXkcayHuUwHaDluiurX5gsE5ryAiaUwAmgmg2o0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Florian Fainelli , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.20 16/60] net: dsa: bcm_sf2: Do not assume DSA master supports WoL Date: Wed, 13 Mar 2019 15:09:37 -0400 Message-Id: <20190313191021.158171-16-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190313191021.158171-1-sashal@kernel.org> References: <20190313191021.158171-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Florian Fainelli [ Upstream commit c3152ec4c0691e351f35a2f63347a464b5f35151 ] We assume in the bcm_sf2 driver that the DSA master network device supports ethtool_ops::{get,set}_wol operations, which is not a given. Avoid de-referencing potentially non-existent function pointers and check them as we should. Fixes: 96e65d7f3f88 ("net: dsa: bcm_sf2: add support for Wake-on-LAN") Signed-off-by: Florian Fainelli Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/dsa/bcm_sf2.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c index 2eb68769562c..5c00dfb6684a 100644 --- a/drivers/net/dsa/bcm_sf2.c +++ b/drivers/net/dsa/bcm_sf2.c @@ -723,10 +723,11 @@ static void bcm_sf2_sw_get_wol(struct dsa_switch *ds, int port, { struct net_device *p = ds->ports[port].cpu_dp->master; struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds); - struct ethtool_wolinfo pwol; + struct ethtool_wolinfo pwol = { }; /* Get the parent device WoL settings */ - p->ethtool_ops->get_wol(p, &pwol); + if (p->ethtool_ops->get_wol) + p->ethtool_ops->get_wol(p, &pwol); /* Advertise the parent device supported settings */ wol->supported = pwol.supported; @@ -747,9 +748,10 @@ static int bcm_sf2_sw_set_wol(struct dsa_switch *ds, int port, struct net_device *p = ds->ports[port].cpu_dp->master; struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds); s8 cpu_port = ds->ports[port].cpu_dp->index; - struct ethtool_wolinfo pwol; + struct ethtool_wolinfo pwol = { }; - p->ethtool_ops->get_wol(p, &pwol); + if (p->ethtool_ops->get_wol) + p->ethtool_ops->get_wol(p, &pwol); if (wol->wolopts & ~pwol.supported) return -EINVAL; -- 2.19.1