Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3404911pxt; Tue, 10 Aug 2021 02:52:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJa1k52JY8QEyYbMxrHaL73Y+Z8OpcAX8n4i6/zEIiOWSCdtmXN731mRBkW8MnwdlW5kEl X-Received: by 2002:a05:6e02:190d:: with SMTP id w13mr51621ilu.53.1628589137300; Tue, 10 Aug 2021 02:52:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628589137; cv=none; d=google.com; s=arc-20160816; b=LXIpg2uXzi2GsdvSugeFnbrugWQYRh5q5eNxNpqm2dd6gKA9Dv6KWjts/bYC1QxTd2 Qy6k7QF7q9vd6pXn1OJZIccBQwRHgajwokJqVx9tFzj6RzoaJCN+XbBHB/jLxlaQg+tI klQ+yphA/rCuSJr51odfPCyL8jtm7LWs7ufj/d94NWqJ7vie/Ejb1zxLmQ57jsTZkA33 HR7E56T8Lt/ZLrR/bgA3HMqTcqVVVj1GaKgGBzALCNmdfW6a1Al0hUCTD2iYrthOLQHe DXnUsBWpcoYEVTVbdlILEZubJW6soEeLXINI7ByDHgIOT/IV2I4JYx186Mi+NiC6yioU korA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=KBFwjkXCjP0BPMcfyhJV7FzUIltUjpzyvNoV0Leciqs=; b=0Ti6NKvS0tS24vNCYyP3kK/DojyVKkWB4d5xFFhRQGpYB2RPnhz2T6ShLhwG+VSTjW 9AO5R0ABbO7lJ2Tc3SNtLYqUpPN+SXNWMu9mmVJ69tCMGLwsaRSF4AdKsdSPzP3e+WKf tG5lLGgCI98RAH6GYAecekS9jVqgn0ISu3jkfPZp0wyTJSq6AuOPZHGty0QPxgWjKZqX T448lCttzbjHFtHdAkDd46U9KhLhqGkijweefGx8f7U0HKSjrw/cPhgxlo8bzOiO2txk Ra6kKmL9GqINpZ4bHDBBraTDKBg1mG3CbD3LTNvG01xUyExuqVlwVMaNi629sinfqK16 QgPw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b24si20332256jar.119.2021.08.10.02.52.06; Tue, 10 Aug 2021 02:52:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236306AbhHJIdq (ORCPT + 99 others); Tue, 10 Aug 2021 04:33:46 -0400 Received: from mga14.intel.com ([192.55.52.115]:14775 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229564AbhHJIdo (ORCPT ); Tue, 10 Aug 2021 04:33:44 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10070"; a="214590714" X-IronPort-AV: E=Sophos;i="5.84,309,1620716400"; d="scan'208";a="214590714" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Aug 2021 01:33:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,309,1620716400"; d="scan'208";a="483961752" Received: from linux.intel.com ([10.54.29.200]) by fmsmga008.fm.intel.com with ESMTP; 10 Aug 2021 01:33:17 -0700 Received: from linux.intel.com (vwong3-iLBPG3.png.intel.com [10.88.229.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by linux.intel.com (Postfix) with ESMTPS id 8C3CD580922; Tue, 10 Aug 2021 01:33:15 -0700 (PDT) Date: Tue, 10 Aug 2021 16:33:12 +0800 From: Wong Vee Khee To: Vladimir Oltean Cc: Vladimir Oltean , Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S . Miller" , Jakub Kicinski , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" Subject: Re: [PATCH net 1/1] net: dsa: sja1105: fix error handling on NULL returned by xpcs_create() Message-ID: <20210810083312.GA30383@linux.intel.com> References: <20210810063513.1757614-1-vee.khee.wong@linux.intel.com> <20210810082528.rff3aembgge62pd6@skbuf> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210810082528.rff3aembgge62pd6@skbuf> User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 10, 2021 at 08:25:29AM +0000, Vladimir Oltean wrote: > Hi VK, > > On Tue, Aug 10, 2021 at 02:35:13PM +0800, Wong Vee Khee wrote: > > There is a possibility xpcs_create() returned a NULL and this is not > > handled properly in the sja1105 driver. > > > > Fixed this by using IS_ERR_ON_NULL() instead of IS_ERR(). > > > > Fixes: 3ad1d171548e ("net: dsa: sja1105: migrate to xpcs for SGMII") > > Cc: Vladimir Olten > > Signed-off-by: Wong Vee Khee > > --- > > drivers/net/dsa/sja1105/sja1105_mdio.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/net/dsa/sja1105/sja1105_mdio.c b/drivers/net/dsa/sja1105/sja1105_mdio.c > > index 19aea8fb76f6..2c69a759ce6e 100644 > > --- a/drivers/net/dsa/sja1105/sja1105_mdio.c > > +++ b/drivers/net/dsa/sja1105/sja1105_mdio.c > > @@ -438,7 +438,7 @@ static int sja1105_mdiobus_pcs_register(struct sja1105_private *priv) > > } > > > > xpcs = xpcs_create(mdiodev, priv->phy_mode[port]); > > - if (IS_ERR(xpcs)) { > > + if (IS_ERR_OR_NULL(xpcs)) { > > rc = PTR_ERR(xpcs); > > goto out_pcs_free; > > } > > -- > > 2.25.1 > > > > I think posting to 'net' is a bit drastic for this patch. I agree it is > an issue but it has bothered absolutely nobody so far, and if sending > this patch to 'net' means you'll be blocked with your patches until the > 'net'->'net-next' merge, I'm not sure it's worth it. > Sounds reasonable for me. I will marked V2 to target net-next. > Anyway, I don't think that PTR_ERR(xpcs) does the right thing when > IS_NULL(xpcs). So how about you make this change: > > -----------------------------[ cut here ]----------------------------- > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c > index a5d150c5f3d8..ca12bf986d4d 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c > @@ -415,7 +415,7 @@ int stmmac_xpcs_setup(struct mii_bus *bus) > continue; > > xpcs = xpcs_create(mdiodev, mode); > - if (IS_ERR_OR_NULL(xpcs)) { > + if (IS_ERR(xpcs)) { > mdio_device_free(mdiodev); > continue; > } > diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c > index 63fda3fc40aa..4bd61339823c 100644 > --- a/drivers/net/pcs/pcs-xpcs.c > +++ b/drivers/net/pcs/pcs-xpcs.c > @@ -1089,7 +1089,7 @@ struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, > > xpcs = kzalloc(sizeof(*xpcs), GFP_KERNEL); > if (!xpcs) > - return NULL; > + return ERR_PTR(-ENOMEM); > > xpcs->mdiodev = mdiodev; > > -----------------------------[ cut here ]-----------------------------