Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2514095imm; Thu, 7 Jun 2018 11:57:42 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJkVPsB6ii6Ec+w1H38UOSU+Uy4FJKh5OFaLXyJlgBigaINzPqTWqHuj1oCkAGZn5yzo9VY X-Received: by 2002:a62:9b57:: with SMTP id r84-v6mr2874379pfd.157.1528397862801; Thu, 07 Jun 2018 11:57:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528397862; cv=none; d=google.com; s=arc-20160816; b=C6fh8TKxqncuAVmKG6fhjgFbB8J4VNLuHJIsrdz6AkfCLJqajbVm+xUkVV/lqWgbMH YmGJol7mmaB2MmfD0pPFoG8Gg9sVLTofSue9e1xjAqCTr1OsW/FfrmVANetNsjQuYQaN mhYT43mAJetQee3dMI9orY/XoiS7GzB2YHvKg4bdi9Aot1QvoekKXk1rK1EkPOuUR1B8 vvq4XvmGjXzj/aRjQvIv3UaJ0DzvzNMzJYlsOtzjPd0j+wEFQQS22NJp1VVT78jrmP51 lsAJhFLCm5ix98zig4jra78kbM3lCzOHYeOgNwtxnVq4q1y94L0Fg7mlxcRj35ME6sIw KGMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=a2gjzIL1fdyv2EzDYKJpbqud9097dSylY9ctSp7JMUA=; b=bnehNKqpPsZrCsp8sO9Ey3MUeglVwN3VoqeXzwbbzW1Ds2AwqVsK3uPcbnTxxDaVes KfhWR+UOHEzd987JAB3ik5BXIsEX5G3wc/5ow02VBR4KuSsn6QPHmtq0E3olaAfiprp5 CeRSYyvJzJJ/E6N4GvtrS4dyoRPbutOFsikXdheessW1c+AMZCkwRknecZpue9fXgMJk YdHJQ1yN+PsZpUDH+vofjqgV4QflLmqNLecaOFjTaKW5oGDmyttiPdCdmPCug/Jj2Z8y zUuUy52gogqSubOJe1NDwW5V992mOKmiLRakht9p38WyzOXexmq/9rzDXlswbAB3Qv82 J/5w== ARC-Authentication-Results: i=1; mx.google.com; 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 w13-v6si4848414pgo.542.2018.06.07.11.57.28; Thu, 07 Jun 2018 11:57:42 -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; 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 S935983AbeFGQGY (ORCPT + 99 others); Thu, 7 Jun 2018 12:06:24 -0400 Received: from da1vs01.rockwellcollins.com ([205.175.227.27]:60116 "EHLO da1vs01.rockwellcollins.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933058AbeFGQGT (ORCPT ); Thu, 7 Jun 2018 12:06:19 -0400 X-Greylist: delayed 574 seconds by postgrey-1.27 at vger.kernel.org; Thu, 07 Jun 2018 12:06:19 EDT Received: from ofwda1n02.rockwellcollins.com (HELO ciulimr02.rockwellcollins.com) ([205.175.227.14]) by da1vs01.rockwellcollins.com with ESMTP; 07 Jun 2018 10:56:44 -0500 X-Received: from righttwix.rockwellcollins.com (righttwix.rockwellcollins.com [192.168.141.218]) by ciulimr02.rockwellcollins.com (Postfix) with ESMTP id 4E3BD20094; Thu, 7 Jun 2018 10:56:44 -0500 (CDT) From: Brandon Maier To: netdev@vger.kernel.org Cc: andrew@lunn.ch, f.fainelli@gmail.com, davem@davemloft.net, michal.simek@xilinx.com, clayton.shotwell@rockwellcollins.com, kristopher.cory@rockwellcollins.com, linux-kernel@vger.kernel.org, Brandon Maier Subject: [PATCH 1/3] net: phy: Check phy_driver ready before accessing Date: Thu, 7 Jun 2018 10:53:46 -0500 Message-Id: <20180607155348.149665-1-brandon.maier@rockwellcollins.com> X-Mailer: git-send-email 2.14.3 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since a phy_device is added to the global mdio_bus list during phy_device_register(), but a phy_device's phy_driver doesn't get attached until phy_probe(). It's possible of_phy_find_device() in xgmiitorgmii will return a valid phy with a NULL phy_driver. Leading to a NULL pointer access during the memcpy(). Signed-off-by: Brandon Maier --- drivers/net/phy/xilinx_gmii2rgmii.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/phy/xilinx_gmii2rgmii.c b/drivers/net/phy/xilinx_gmii2rgmii.c index 2e5150b0b8d5..04c8bec1c4c1 100644 --- a/drivers/net/phy/xilinx_gmii2rgmii.c +++ b/drivers/net/phy/xilinx_gmii2rgmii.c @@ -81,6 +81,11 @@ static int xgmiitorgmii_probe(struct mdio_device *mdiodev) return -EPROBE_DEFER; } + if (!priv->phy_dev->drv) { + dev_info(dev, "Attached phy not ready\n"); + return -EPROBE_DEFER; + } + priv->addr = mdiodev->addr; priv->phy_drv = priv->phy_dev->drv; memcpy(&priv->conv_phy_drv, priv->phy_dev->drv, -- 2.14.3