From patchwork Fri Feb 22 19:54:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 1047104 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=netronome.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="QtjEKEwv"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 445hqz5jTDz9sBL for ; Sat, 23 Feb 2019 06:54:23 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726964AbfBVTyW (ORCPT ); Fri, 22 Feb 2019 14:54:22 -0500 Received: from mail-qt1-f194.google.com ([209.85.160.194]:35974 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726870AbfBVTyV (ORCPT ); Fri, 22 Feb 2019 14:54:21 -0500 Received: by mail-qt1-f194.google.com with SMTP id p25so3923930qtb.3 for ; Fri, 22 Feb 2019 11:54:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=G7WO8kh5U1TvdM1SCF+Z3WJZnweGpcuresnBJgqjhac=; b=QtjEKEwveTXc93eFMvm1SbOj+LK2w/iQ6BR2iFtKdPNFX+Q1N0KqY1eDp+isPTbEB+ CoczZ1FP3iwpjgcjt3rovWOybqGE1kTpGjKqehlzLWvHROwZMnFtliIM2j4DyZkPFIcl Cf1FHm3dx0trrSqg/icSh7CFYPoM692g6t3+YUD4Ea7p6ux4KnuIvuq3x/UsAgqagbxA AlRNF/tbSJeMKIR2m6PbFVG33XJupZSSTaqJHH2nR1jRbEEc1HTH9c7p28eAoY21kkB5 of0sKsjCGZWmlBJCD+q6B0Zx5ulZ6ZxWyEsh7cHajAaiDadXAhLwfyLLhB3YDdj6w65J Vd2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=G7WO8kh5U1TvdM1SCF+Z3WJZnweGpcuresnBJgqjhac=; b=rBqHmt5X0TaQ00cZg0dD+y5o5XWafRwsUTW4XFSFKJFI2sfo94Jeie/g4TNt6300uh 6ecEqeQUjJBAjBADxuMdoZaJV9MdEZEE791A5QAHhEaf2kcQsIibCqylAVKclNqkCpvf TzSoo20IsLOaKpQ3X4ariCg1FF8UUuch501Ck+/vKFq99ztUUkJJXInI1MyD0mWFDkqy dIbP2Y5yXEDu87WUN+ZNUH0hLXhncR7qRq4r4rNtC4yhG7BgQSbq9LW8f4I3fkvUSlVl WOWC+sZgfbM4TKukaX1oTTJd8jn33Z82lEw3oBDAM2DS+XU4RGaQ8yWbI1zE7PMK1hMt DHYg== X-Gm-Message-State: AHQUAuZq2kIhTsow9XXcyzBOTOGuABDnwdXXTRZobXr/GPmjXeAz7t+5 WEjllyFdL43laH48gCRxD7S8g8GyY1M= X-Google-Smtp-Source: AHgI3IbhLPq/PKC98zeQaqr/CVpwsNh9/1tz6Ihma9Y6s7KPsKL4vdYJ5zrM7RXuJkLSeCdVRCrK/A== X-Received: by 2002:ac8:3855:: with SMTP id r21mr4213285qtb.91.1550865260693; Fri, 22 Feb 2019 11:54:20 -0800 (PST) Received: from jkicinski-Precision-T1700.netronome.com ([66.60.152.14]) by smtp.gmail.com with ESMTPSA id r30sm1605280qtj.45.2019.02.22.11.54.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Feb 2019 11:54:20 -0800 (PST) From: Jakub Kicinski To: davem@davemloft.net, jiri@resnulli.us Cc: mkubecek@suse.cz, andrew@lunn.ch, f.fainelli@gmail.com, netdev@vger.kernel.org, oss-drivers@netronome.com, Jakub Kicinski Subject: [PATCH net-next v2 2/5] ethtool: hold a reference to the netdevice around devlink compat Date: Fri, 22 Feb 2019 11:54:07 -0800 Message-Id: <20190222195410.9494-3-jakub.kicinski@netronome.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190222195410.9494-1-jakub.kicinski@netronome.com> References: <20190222195410.9494-1-jakub.kicinski@netronome.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When calling into devlink compat code make sure we have a reference on the netdevice on which the operation was invoked. Signed-off-by: Jakub Kicinski --- net/core/ethtool.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/net/core/ethtool.c b/net/core/ethtool.c index 1320e8dce559..6832476dfcaf 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c @@ -805,11 +805,14 @@ static noinline_for_stack int ethtool_get_drvinfo(struct net_device *dev, if (ops->get_eeprom_len) info.eedump_len = ops->get_eeprom_len(dev); - rtnl_unlock(); - if (!info.fw_version[0]) + if (!info.fw_version[0]) { + dev_hold(dev); + rtnl_unlock(); devlink_compat_running_version(dev, info.fw_version, sizeof(info.fw_version)); - rtnl_lock(); + rtnl_lock(); + dev_put(dev); + } if (copy_to_user(useraddr, &info, sizeof(info))) return -EFAULT; @@ -2043,9 +2046,11 @@ static noinline_for_stack int ethtool_flash_device(struct net_device *dev, if (!dev->ethtool_ops->flash_device) { int ret; + dev_hold(dev); rtnl_unlock(); ret = devlink_compat_flash_update(dev, efl.data); rtnl_lock(); + dev_put(dev); return ret; }