Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7279388imu; Wed, 14 Nov 2018 14:46:06 -0800 (PST) X-Google-Smtp-Source: AJdET5c+Our2VIIkzh1tZsLvin29W330U2ypDtIBhUSGofXhLfIFmIwNs12ObvqkzDtTl8xjTV+L X-Received: by 2002:a65:624c:: with SMTP id q12mr3483002pgv.379.1542235566105; Wed, 14 Nov 2018 14:46:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542235566; cv=none; d=google.com; s=arc-20160816; b=U8ewtCktKeqarqRQwugISgf1mHIGLlVtiZMxOw7b08JlE1ZHA5gG7pLzgBIsusFF4r F/N1JtOYmhz0f/H7Yb2iSVr2xcbux2MZNiEzu9y9/GBXzmSndDU/QPddf+o34BEk023v kITfdBiGv6Pk9go3cgAjtx6SmnEzI8hu9TieNc0j+pwiBPQTnzaGyVmWhurt/BYng2l/ OTi5dlEFMmjEN1LHWwHNTAqhKtxCMglu9qI/OVWS0dR/yMYCENdzTemxl6mEt+g8p9PZ B6WNZd/ZA/kE6F8NwNe9T0LIve9J/60FtQhSga/+vDqVOLDkprmixSR7eqCUIjzlVbAj qoDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=JguXWx1uthP3eonZbUvDnfhJrjytlmkavi1+Tx4iSV0=; b=ZcI+kO4ccLIa0SJ7ifAUlKIcobs2H3pI0Fe8rnSAEp1DVKVnTyIkLKjZE53O25kOnQ HrgBobcby6DPhIh4XRdmx43eF4IYmtd1PS984jrXCVwKIa045GIiIryWRXEdg5LM4+So o9XdqNjbaDMMXvC3yOMPsEWtyZYw2cl2CDJatOnPdNmQl6BpvjYMFr8NH5qoV4LG/NGN S4CDzlmih5okrG4w1xMaPJ8+aOFy0bFsGJRiPvk38LaxZFSygBAColTJNsA4mT7ypLcH odz3ChnHkvA+YxzlBG2NpK7lCaJvnG2AEbngT+msbM27KYdVeB+OqDqFfK5/ub2zKa4U CXyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FAXht+aY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l12-v6si27006412plc.54.2018.11.14.14.45.51; Wed, 14 Nov 2018 14:46:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FAXht+aY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388234AbeKOItI (ORCPT + 99 others); Thu, 15 Nov 2018 03:49:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:34470 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727038AbeKOI1S (ORCPT ); Thu, 15 Nov 2018 03:27:18 -0500 Received: from sasha-vm.mshome.net (unknown [64.114.255.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 706752251A; Wed, 14 Nov 2018 22:22:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542234134; bh=6t8XfduumMFVhI2vt35t9uJVZbAdIDEHpZBYciD+MeU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FAXht+aYSIjXjqVZjR8kwntLqjwoV9PVgzoJpVSZ6/4hMBsMGuHFisr24H5rO44eX y1j8g7c/FDrG4qDH5i5a11Ij9nQuUESg1Sq1BUnn3vwqTPA4K3gibf5bDl8kYX8HCs 5t0Slp4Adx/GmvCJwihw7MriyxFfZFXn6+rici2U= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Julian Wiedmann , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL 4.19 25/73] s390/qeth: unregister netdevice only when registered Date: Wed, 14 Nov 2018 17:21:19 -0500 Message-Id: <20181114222207.98701-25-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181114222207.98701-1-sashal@kernel.org> References: <20181114222207.98701-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Julian Wiedmann [ Upstream commit 30356d08159d7899438e94503ae322a8b881e205 ] qeth only registers its netdevice when the qeth device is first set online. Thus a device that has never been set online will trigger a WARN ("network todo 'hsi%d' but state 0") in unregister_netdev() when removed. Fix this by protecting the unregister step, just like we already protect against repeated registering of the netdevice. Fixes: d3d1b205e89f ("s390/qeth: allocate netdevice early") Reported-by: Karsten Graul Signed-off-by: Julian Wiedmann Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/s390/net/qeth_core.h | 5 +++++ drivers/s390/net/qeth_l2_main.c | 5 +++-- drivers/s390/net/qeth_l3_main.c | 5 +++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/s390/net/qeth_core.h b/drivers/s390/net/qeth_core.h index 34e0d476c5c6..970654fcc48d 100644 --- a/drivers/s390/net/qeth_core.h +++ b/drivers/s390/net/qeth_core.h @@ -826,6 +826,11 @@ struct qeth_trap_id { /*some helper functions*/ #define QETH_CARD_IFNAME(card) (((card)->dev)? (card)->dev->name : "") +static inline bool qeth_netdev_is_registered(struct net_device *dev) +{ + return dev->netdev_ops != NULL; +} + static inline void qeth_scrub_qdio_buffer(struct qdio_buffer *buf, unsigned int elements) { diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c index b5e38531733f..76b2fba5fba2 100644 --- a/drivers/s390/net/qeth_l2_main.c +++ b/drivers/s390/net/qeth_l2_main.c @@ -854,7 +854,8 @@ static void qeth_l2_remove_device(struct ccwgroup_device *cgdev) if (cgdev->state == CCWGROUP_ONLINE) qeth_l2_set_offline(cgdev); - unregister_netdev(card->dev); + if (qeth_netdev_is_registered(card->dev)) + unregister_netdev(card->dev); } static const struct ethtool_ops qeth_l2_ethtool_ops = { @@ -894,7 +895,7 @@ static int qeth_l2_setup_netdev(struct qeth_card *card) { int rc; - if (card->dev->netdev_ops) + if (qeth_netdev_is_registered(card->dev)) return 0; card->dev->priv_flags |= IFF_UNICAST_FLT; diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c index 17e2fd584fbf..b7f6a8384543 100644 --- a/drivers/s390/net/qeth_l3_main.c +++ b/drivers/s390/net/qeth_l3_main.c @@ -2514,7 +2514,7 @@ static int qeth_l3_setup_netdev(struct qeth_card *card) { int rc; - if (card->dev->netdev_ops) + if (qeth_netdev_is_registered(card->dev)) return 0; if (card->info.type == QETH_CARD_TYPE_OSD || @@ -2611,7 +2611,8 @@ static void qeth_l3_remove_device(struct ccwgroup_device *cgdev) if (cgdev->state == CCWGROUP_ONLINE) qeth_l3_set_offline(cgdev); - unregister_netdev(card->dev); + if (qeth_netdev_is_registered(card->dev)) + unregister_netdev(card->dev); qeth_l3_clear_ip_htable(card, 0); qeth_l3_clear_ipato_list(card); } -- 2.17.1