Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4849135imu; Tue, 15 Jan 2019 07:03:18 -0800 (PST) X-Google-Smtp-Source: ALg8bN77OAji3CCvsaKpvjSRbrqmlOgXJs8RZvEGrQpR3gtsE0y3FXHqaX0JSH87lT1Tm+23KYML X-Received: by 2002:a17:902:b282:: with SMTP id u2mr4615018plr.89.1547564598429; Tue, 15 Jan 2019 07:03:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547564598; cv=none; d=google.com; s=arc-20160816; b=tNrjePGAPSZEVLjn7GAMo+8TJSieaRq4M8FuqKH5kzk1jb6AB6GY00ZsbJsl7jcyRC 25BRu6QSJJRfgPCIwvXAppu41JS6LMnVIaNdrf/t/n1F7d6RTr+8f176gWgtu3bQTKa5 H9nytNbghc90VU4tKLhKM3BDbe7mie7aNc3rb5SkQunCvbj4EHWPwBiXue0di9PFinay 2iIYtwJcnltfuqhtXB8d6Zi1Gmxh4539ALXF4eazhksGsls5QgebY2Ttns6wWfc8Za2l UmAXZbfWW4CE8CMfovL6uwcdKXLc7JHGwYQxCMK07KMl/KIBqaGwVp48xDp2piPpL7S+ GAqw== 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; bh=nyh2530G+dPCx726/bLOx8BVH8MwjssH6wTk1IBMNWo=; b=lVJ4WfjRX5k4L+CPZVJcSNI3r66rKWT1mbhLqYL1mq8vLyX0ivEiCnf9FyJHS8GROV lsdiaDEP78LA37KlaUVWNCJtqp2TufFDAEGZKwq8g3SM5JPzjihUY4/f0h7shWAG8qHl /vO+bmqYBC6OFYy8+y9d/b9sY+lI4gNgQ5Xr4JO8Cpo83sH0DXaJbtYfG9Tiqa+ACUUo nyqf9h/5rvIY4dYSiQ4BLAxx1c6OIpfWUJYeHAVJLG+LQLanROwczCNlzDEM7nck66T5 HISTp4SV9ib1FRHYKL28QSsjB7yAcgUkIw9Id7vtGf+9jrZKWTInLMSIj6pACG6yfPkl wplg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v9si547449pfl.45.2019.01.15.07.02.57; Tue, 15 Jan 2019 07:03:18 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729048AbfAOMfs (ORCPT + 99 others); Tue, 15 Jan 2019 07:35:48 -0500 Received: from inva021.nxp.com ([92.121.34.21]:44996 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727439AbfAOMfs (ORCPT ); Tue, 15 Jan 2019 07:35:48 -0500 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id AFE5B2000B1; Tue, 15 Jan 2019 13:35:45 +0100 (CET) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id A234C20003B; Tue, 15 Jan 2019 13:35:45 +0100 (CET) Received: from fsr-ub1464-019.ea.freescale.net (fsr-ub1464-019.ea.freescale.net [10.171.81.207]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id 46553205DC; Tue, 15 Jan 2019 13:35:45 +0100 (CET) From: Camelia Groza To: andrew@lunn.ch, f.fainelli@gmail.com, hkallweit1@gmail.com, davem@davemloft.net, oss@buserror.net Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Camelia Groza Subject: [PATCH net] net: phy: phy driver features are mandatory Date: Tue, 15 Jan 2019 14:35:19 +0200 Message-Id: <1547555719-13541-1-git-send-email-camelia.groza@nxp.com> X-Mailer: git-send-email 1.9.1 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since phy driver features became a link_mode bitmap, phy drivers that don't have a list of features configured will cause the kernel to crash when probed. Prevent the phy driver from registering if the features field is missing. Fixes: 719655a14971 ("net: phy: Replace phy driver features u32 with link_mode bitmap") Reported-by: Scott Wood Signed-off-by: Camelia Groza --- This patch should be merged to 4.20 stable. --- drivers/net/phy/phy_device.c | 3 +++ include/linux/phy.h | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 5199000..f70dfb3 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2243,6 +2243,9 @@ int phy_driver_register(struct phy_driver *new_driver, struct module *owner) { int retval; + if (WARN_ON(!new_driver->features)) + return -EINVAL; + new_driver->mdiodrv.flags |= MDIO_DEVICE_IS_PHY; new_driver->mdiodrv.driver.name = new_driver->name; new_driver->mdiodrv.driver.bus = &mdio_bus_type; diff --git a/include/linux/phy.h b/include/linux/phy.h index 3b051f7..ec3b6d5 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -467,8 +467,8 @@ struct phy_device { * only works for PHYs with IDs which match this field * name: The friendly name of this PHY type * phy_id_mask: Defines the important bits of the phy_id - * features: A list of features (speed, duplex, etc) supported - * by this PHY + * features: A mandatory list of features (speed, duplex, etc) + * supported by this PHY * flags: A bitfield defining certain other features this PHY * supports (like interrupts) * -- 1.9.1