From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D568C04EB8 for ; Fri, 30 Nov 2018 19:01:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D452020834 for ; Fri, 30 Nov 2018 19:01:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="WV+xOH8M" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D452020834 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726887AbeLAGLN (ORCPT ); Sat, 1 Dec 2018 01:11:13 -0500 Received: from pandora.armlinux.org.uk ([78.32.30.218]:58854 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726564AbeLAGLN (ORCPT ); Sat, 1 Dec 2018 01:11:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2014; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=cgLqnsGOzZTpWIhpPCkX25BM43oTGYD8p0WI42VHhW0=; b=WV+xOH8M2NgemEIYzcxbfR8HW wv2yBSh9Tg7I8OZ1D6HJIoI3rSnIDzOiGa7bCDPW9b+KSjr8tqybiMXhYx8OWyPub6AQEm/IE/a53 L/3F5NlzZEAOqKdVF7Z/D2MoP70TuvG//jhW+3AYISsLcY2uegAbo+0fK0gNvjuMfo18E=; Received: from n2100.armlinux.org.uk ([fd8f:7570:feb6:1:214:fdff:fe10:4f86]:56909) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.90_1) (envelope-from ) id 1gSo1t-0001V7-5s; Fri, 30 Nov 2018 19:00:45 +0000 Received: from linux by n2100.armlinux.org.uk with local (Exim 4.90_1) (envelope-from ) id 1gSo1k-0002CJ-Ur; Fri, 30 Nov 2018 19:00:37 +0000 Date: Fri, 30 Nov 2018 19:00:31 +0000 From: Russell King - ARM Linux To: Miquel Raynal Cc: Gregory Clement , Jason Cooper , Andrew Lunn , Sebastian Hesselbarth , Kishon Vijay Abraham I , Mark Rutland , devicetree@vger.kernel.org, Antoine Tenart , Grzegorz Jaszczyk , linux-kernel@vger.kernel.org, Maxime Chevallier , Nadav Haklai , Rob Herring , Thomas Petazzoni , Marcin Wojtas , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 2/8] phy: mvebu-cp110-comphy: fix port check in ->xlate() Message-ID: <20181130190031.GH30658@n2100.armlinux.org.uk> References: <20181130144743.675-1-miquel.raynal@bootlin.com> <20181130144743.675-3-miquel.raynal@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181130144743.675-3-miquel.raynal@bootlin.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 30, 2018 at 03:47:37PM +0100, Miquel Raynal wrote: > So far the PHY ->xlate() callback was checking if the port was > "invalid" before continuing, meaning that the port has not been used > yet. This check is not correct as there is no opposite call to > ->xlate() once the PHY is released by the user and the port will > remain "valid" after the first phy_get()/phy_put() calls. Hence, if > this driver is built as a module, inserted, removed and inserted > again, the PHY will appear busy and the second probe will fail. > > To fix this, just drop the faulty check and instead verify that the > port number is valid (ie. in the possible range). > > Signed-off-by: Miquel Raynal > --- > drivers/phy/marvell/phy-mvebu-cp110-comphy.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/phy/marvell/phy-mvebu-cp110-comphy.c b/drivers/phy/marvell/phy-mvebu-cp110-comphy.c > index 31b9a1c18345..a40b876ff214 100644 > --- a/drivers/phy/marvell/phy-mvebu-cp110-comphy.c > +++ b/drivers/phy/marvell/phy-mvebu-cp110-comphy.c > @@ -567,9 +567,9 @@ static struct phy *mvebu_comphy_xlate(struct device *dev, > return phy; > > lane = phy_get_drvdata(phy); > - if (lane->port >= 0) > - return ERR_PTR(-EBUSY); > lane->port = args->args[0]; > + if (lane->port >= MVEBU_COMPHY_PORTS) > + return ERR_PTR(-EINVAL); Shouldn't we validate args->args[0] before doing anything? -- RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up