From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="RC1f7nvb" Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8332D4C; Wed, 13 Dec 2023 07:45:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; 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=RQ3wc5JxvIn7TWgkZzitesTubhuMcown2Fe6VgEWQMw=; b=RC1f7nvb1Lmp4iGlF8Dymy6bZy yzZVqCnYhYW44/PO7iRvfAAXnYnUJUfhOdZ3dxN05qbyLlP27DZIISio6Snx0BRIxLUbDqA9uTrbB bz7OP2HHlOI2c+5jkDNnlKt/rFGXkFN7dwhvo+ZfawF0506SNKGwWNnwE043hhanTQRXO7CzUWTFg KoZtq1O9ktg3gCp4xjn5oCebYP6Ye74iyHsBeEHndOhq+iODJM5o1wdBIgOQALrpcmk8z72ARMkPn LG1sYsTAvIOG4TpFOd9wTAsgjvkdWYVuMraPpluEHw5Rkwk75hySrJzuJwMJrsP5rsjSn3OHUgMUL PyX5xZqg==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:53372) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rDRQI-0000B1-2n; Wed, 13 Dec 2023 15:45:22 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rDRQK-0001cW-HO; Wed, 13 Dec 2023 15:45:24 +0000 Date: Wed, 13 Dec 2023 15:45:24 +0000 From: "Russell King (Oracle)" To: Christian Marangi Cc: Florian Fainelli , Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vladimir Oltean , David Epping , Harini Katakam , Simon Horman , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [net-next PATCH v6 1/3] net: phy: extend PHY package API to support multiple global address Message-ID: References: <20231213105730.1731-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231213105730.1731-1-ansuelsmth@gmail.com> Sender: Russell King (Oracle) On Wed, Dec 13, 2023 at 11:57:28AM +0100, Christian Marangi wrote: > -static inline int phy_package_read(struct phy_device *phydev, u32 regnum) > +static inline int phy_package_read(struct phy_device *phydev, > + unsigned int addr_offset, u32 regnum) > { > struct phy_package_shared *shared = phydev->shared; > + int addr = shared->base_addr + addr_offset; > > - if (!shared) > + if (addr >= PHY_MAX_ADDR) > return -EIO; If we're going to check the address, I think we should check it properly, which means also checking whether it's become negative. Alternatively, we could consider making "addr" and "base_addr" unsigned types, since they should never be negative. However, that probably should be done as a separate patch before this one. Thanks. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!