From nobody Wed Sep 17 01:46:40 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA8D6C3DA79 for ; Mon, 26 Dec 2022 11:48:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231693AbiLZLsp (ORCPT ); Mon, 26 Dec 2022 06:48:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbiLZLsn (ORCPT ); Mon, 26 Dec 2022 06:48:43 -0500 Received: from forwardcorp1a.mail.yandex.net (forwardcorp1a.mail.yandex.net [178.154.239.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93A3D2FB; Mon, 26 Dec 2022 03:48:42 -0800 (PST) Received: from vla1-81430ab5870b.qloud-c.yandex.net (vla1-81430ab5870b.qloud-c.yandex.net [IPv6:2a02:6b8:c0d:35a1:0:640:8143:ab5]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTP id CEFD85FCE7; Mon, 26 Dec 2022 14:48:40 +0300 (MSK) Received: from d-tatianin-nix.yandex-team.ru (unknown [2a02:6b8:b081:1::1:f]) by vla1-81430ab5870b.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id SmMqpV0Q0uQ1-IbutsOwc; Mon, 26 Dec 2022 14:48:40 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1672055320; bh=Wl46n9GzEekweDAs/Z8zerV+l+QIWCUnBlczJiEGt0c=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=q0UggCoPnCZNu0GuMmnwmxZbLUamlM5m0fItS/NudL461zYOxkjVZNcZKAWq2o0qs Xle0rtoLgw3/FbSBJfmjoWfGUOfmnanmGbllRKf5m5E98WOn7E47L7RCIZLanO5lon MU8y+Yp6UgZbTIDelR6lxq2J/kHiUFhW1xydSGQs= Authentication-Results: vla1-81430ab5870b.qloud-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Daniil Tatianin To: "David S. Miller" Cc: Daniil Tatianin , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Sean Anderson , Jiri Pirko , Wolfram Sang , Maxim Korotkov , Gal Pressman , Vincent Mailhol , Tom Rix , Marco Bonelli , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net v2 1/3] net/ethtool/ioctl: return -EOPNOTSUPP if we have no phy stats Date: Mon, 26 Dec 2022 14:48:23 +0300 Message-Id: <20221226114825.1937189-2-d-tatianin@yandex-team.ru> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221226114825.1937189-1-d-tatianin@yandex-team.ru> References: <20221226114825.1937189-1-d-tatianin@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 --- 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 57e7238a4136..e8a294b38b7b 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -2093,7 +2093,8 @@ static int ethtool_get_phy_stats(struct net_device *d= ev, 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; =20 if (copy_from_user(&stats, useraddr, sizeof(stats))) return -EFAULT; --=20 2.25.1