From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 761957E for ; Sun, 22 Jan 2023 15:11:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB865C433EF; Sun, 22 Jan 2023 15:11:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1674400285; bh=Ml9/XpIrujd9fA8j46izKKPpTquPXiz4Gq+WV7YeRPg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kNn6dRe8HCaJbXAjysi14G15YwIzLCh1zaiFwKKk/EeeuM8PnczAXRxJl7PT9sBos JBtgHlsId5rzHuycKGuyoGywpTLQYlz7Is1RpSSVNaw/3rljkWNtjc1kPVquAzm5LB zXRrRRoiPs0CAPwObo6iZIuGpkk+6Ac4tAz6dmpg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Daniil Tatianin , Andrew Lunn , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 05/98] net/ethtool/ioctl: return -EOPNOTSUPP if we have no phy stats Date: Sun, 22 Jan 2023 16:03:21 +0100 Message-Id: <20230122150229.620565267@linuxfoundation.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230122150229.351631432@linuxfoundation.org> References: <20230122150229.351631432@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Daniil Tatianin [ Upstream commit 9deb1e9fb88b1120a908676fa33bdf9e2eeaefce ] It's not very useful to copy back an empty ethtool_stats struct and return 0 if we didn't actually have any stats. This also allows for further simplification of this function in the future commits. Signed-off-by: Daniil Tatianin Reviewed-by: Andrew Lunn Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ethtool/ioctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index 47c2dd4a9b9f..12bf740e2fb3 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -2052,7 +2052,8 @@ static int ethtool_get_phy_stats(struct net_device *dev, void __user *useraddr) return n_stats; if (n_stats > S32_MAX / sizeof(u64)) return -ENOMEM; - WARN_ON_ONCE(!n_stats); + if (WARN_ON_ONCE(!n_stats)) + return -EOPNOTSUPP; if (copy_from_user(&stats, useraddr, sizeof(stats))) return -EFAULT; -- 2.35.1