Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9964380ybi; Wed, 24 Jul 2019 13:09:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqyiGvj9Mib1kJcdPpZTzvwT0IwsIQqAlFv7qlluuNuOCYfDjsoCcwOerW0kA3Jp4hAFCMIe X-Received: by 2002:a17:90a:270f:: with SMTP id o15mr89305064pje.56.1563998988663; Wed, 24 Jul 2019 13:09:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563998988; cv=none; d=google.com; s=arc-20160816; b=sYW6xKYOqLuMOXhT93Qf7C2Kg0wdh8k1hIlQG8twe1OSBK+nwC6BDxpXi6foX9JANO W7Bw/UuRbXt+GDwSu+FNsWHpazkdMy/92ZwbYb10n7SSVH48KAug+/+Av3h9lXiYxKvH 9TA6Ku4TQa4P8jWwSv8xk37kaLQGAYLKMoyBJ8Ej/Tb+mn/eIC8w1cAOEVn1Xp+L95Nk Yeyd8WHNCauroT9j9PY+bX53L5rY1IUPCjSBcufDvc8ZGGegB5WuY2eqDvJsXr9feaGo dBTAAD+Ci8jOY2Jd0yzV5ZZJPulGzWZGKxBG9qK7/qXFtJ7EzjSjfzp4YnP9k02IZBPa fpGg== 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=K1S8811ave2yIKWGk1/ZAZVnHzjRtr0fsiaSbmoC1iE=; b=VF4e6Sm1wHfjoIvBJQkUNvOvjStLFdQGzhNtkEwV7Zq1Xiuvo49bCcprfJAwTVsShi 0wHZv+EBekGA2vccKdiBgCixUGpGenrpPb5+xA6pnyh9l9eEUqhSYXj6iUq7Pc1lG5cJ X5XryYMJuoKIrXSn4ZJhj/qpFSAm1y1XTQjsJLil3ahyX1ZZN/MI97we69MHabBalL9D XiETuMLdb6YGdHFFy09Ns025dUKlwcma1p3NhQ1ScIIBANasI1kCPPVDKJsh3QNV7iHD tn9PR+7Rmv9Y1JL8YBGCG7lyuXMh5Yd6asBLAOP5p7R35fNt5r28m+h9g2oBvJX1LKVN L6tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nVxzjf2k; 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 k129si6228585pgk.42.2019.07.24.13.09.33; Wed, 24 Jul 2019 13:09:48 -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=nVxzjf2k; 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 S2392303AbfGXUIQ (ORCPT + 99 others); Wed, 24 Jul 2019 16:08:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:52612 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405546AbfGXUCk (ORCPT ); Wed, 24 Jul 2019 16:02:40 -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 C598C205C9; Wed, 24 Jul 2019 20:02:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563998559; bh=6EiICUsb6HjmNZYOgRG27KFcWBhfBMswqXzrv0cMlJs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nVxzjf2kr0D8B62yZIqB8PVLdehFfxYoafCnk/w3hnFqI2jnl1i4jrBN280ppaRXr hoxgdJYC3NKiKqjgo7Bp9ub4heVP0Opyf9Q+wFQYmOKRWU8oYcsWVwmsGG4yZXnZRW zFPiBthikTmqH7coqDhRSisWrG8fY1aagomwcTSE= 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 4.19 034/271] net: phy: Check against net_device being NULL Date: Wed, 24 Jul 2019 21:18:23 +0200 Message-Id: <20190724191658.123046892@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191655.268628197@linuxfoundation.org> References: <20190724191655.268628197@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 8a96d985a52f..6144146aec29 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -757,6 +757,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; @@ -1098,6 +1101,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