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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B80AAC27C76 for ; Sun, 22 Jan 2023 15:20:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231251AbjAVPUt (ORCPT ); Sun, 22 Jan 2023 10:20:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231249AbjAVPUs (ORCPT ); Sun, 22 Jan 2023 10:20:48 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9996222EC for ; Sun, 22 Jan 2023 07:20:47 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 52A0160C63 for ; Sun, 22 Jan 2023 15:20:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63C61C433EF; Sun, 22 Jan 2023 15:20:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1674400846; bh=I7Zc6ryRLMpOEdl2D6K7yGFNllAyjuEiLhezdwLGmHs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZCNaB2yW9UGNyqGHgmZpeytRXRY9rmoQVcosNMLZXz82lDvVUuBWWXSW/JWJidPrH Q6eD5za1GDPEafMXQmtelzWNbnUGtYI46PmCxQdn8bc29SnlAD5oP8hzieqt9VpGeK B9r3Kb919M803Bs3Q9xjDs0hp7ohUFiaQd9oSgCk= 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 6.1 014/193] net/ethtool/ioctl: return -EOPNOTSUPP if we have no phy stats Date: Sun, 22 Jan 2023 16:02:23 +0100 Message-Id: <20230122150247.020424511@linuxfoundation.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230122150246.321043584@linuxfoundation.org> References: <20230122150246.321043584@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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 81fe2422fe58..038398d41a93 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -2094,7 +2094,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