Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9988738ybi; Wed, 24 Jul 2019 13:38:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6CGk2nAF5mBcBA76U1NOSg5EpBMopDjV8DM/MwiR8ZgCUhlUoXO1tMIHnYVkf2oqr6g5/ X-Received: by 2002:a17:902:f301:: with SMTP id gb1mr86066993plb.292.1564000727408; Wed, 24 Jul 2019 13:38:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564000727; cv=none; d=google.com; s=arc-20160816; b=twpz48CIbCHRR1AZJEJ6eQFX4y0hctZPwbEwI2gNnXaKM4zFXzJ6NTH1OOwqoTgTxo 7ivVmcT1uiAJmSo/7hmcIsosVGqVfqtn0jBPGn9Zk7jfjnKYWBSfuUo87q+cIoDnbdTY ApLbOT6J3WT79MlQhKMhPfgzmD97YIBOkC7KbyZ4FE6/NEuXXIBFbZL3PC2JEpj3Fv6M 0kDPV9lipB3XluCnApn+XV4vmhA7+9eMtT+6EQbVA1POF40e9e3cazVnM7MqTfcO0NRX SH2FOICJTM9pvXVYxGSIaeFHiNnziXm3OhJKa0s5780Ws5ltZs676mwHvZKKtrGKmTNT dZJA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uttUYl7AP4JLPAJBYvyUQ5L0hWurcOlsu2APSB5zIDs=; b=Js3FYIAEq+JonAcoXWydAG2mX33Ei7f9Qm+PFOF4wjfqIQd4QkaW4cLE15onARvsf0 J83Hd+zpFMswjlBOO9a1nys6N/lHcotePqHWuvCf+zaa90JrpSyn5OcZ1op/U4f0hIn7 EOjii1Hqhu2FGY4MDj6KepCTv/t3cmKMOe/26JaWzKKVu3naTsfgU4z4MPcYPMaU3qKQ 4YqX6Py/Zaue2/1UyI35MgC3/81jx6sF+79Mh6I0qlLk9auQteZhVeIFv2H25fxTkJ/3 HWV+iMBGDbdmCD0/GzNsp9wP6KBri/z/5qNO5ybJ1iwbuLf5TCr7PdAXGcA738qtCbhH BrcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nzD3v3JB; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r3si16980115pjd.105.2019.07.24.13.38.32; Wed, 24 Jul 2019 13:38:47 -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=nzD3v3JB; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389411AbfGXUgG (ORCPT + 99 others); Wed, 24 Jul 2019 16:36:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:41758 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729153AbfGXTZI (ORCPT ); Wed, 24 Jul 2019 15:25:08 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 89D17218F0; Wed, 24 Jul 2019 19:25:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563996308; bh=TD9CeuCD1yg7COD4KIQ1mU61LXL0u/g7kCGYzuGd4h8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nzD3v3JBZ3cBEhfG1FwLGoflxSJZTUJ7MZ4bY0P+T0oMdCqb2fQEHuyc6Uvo+/rg8 9ElZJ2CNLJLSr759a3Bqo7G4L7/gTTN+6KHWOj+JkqtDPkYC4/mZHXPTADJhpcIlaJ f8eEBWDsZ0tlnbC/knq0RJE2B93fiBBjISd3jlG4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ioana Ciornei , Andrew Lunn , Florian Fainelli , "David S. Miller" , Sasha Levin Subject: [PATCH 5.2 051/413] net: phy: Check against net_device being NULL Date: Wed, 24 Jul 2019 21:15:42 +0200 Message-Id: <20190724191739.147182446@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 82c76aca81187b3d28a6fb3062f6916450ce955e ] In general, we don't want MAC drivers calling phy_attach_direct with the net_device being NULL. Add checks against this in all the functions calling it: phy_attach() and phy_connect_direct(). Signed-off-by: Ioana Ciornei Suggested-by: Andrew Lunn Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/phy/phy_device.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index dcc93a873174..a3f8740c6163 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -948,6 +948,9 @@ int phy_connect_direct(struct net_device *dev, struct phy_device *phydev, { int rc; + if (!dev) + return -EINVAL; + rc = phy_attach_direct(dev, phydev, phydev->dev_flags, interface); if (rc) return rc; @@ -1290,6 +1293,9 @@ struct phy_device *phy_attach(struct net_device *dev, const char *bus_id, struct device *d; int rc; + if (!dev) + return ERR_PTR(-EINVAL); + /* Search the list of PHY devices on the mdio bus for the * PHY with the requested name */ -- 2.20.1