Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2278366imm; Thu, 7 Jun 2018 08:06:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLVHGTi83Iso79IaaODhPuXpv+52aLO4kJyzZd95UEUQAsZTasN1DLXtr8klxKr0Gfxt79T X-Received: by 2002:a17:902:7888:: with SMTP id q8-v6mr2410151pll.79.1528383985195; Thu, 07 Jun 2018 08:06:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528383985; cv=none; d=google.com; s=arc-20160816; b=WKq9SS/m8RcVshzcRo53CoGX6t/Mcryfquh54UnClOh+pWDyj4B+Nja1gr6VpGbqIt 5XvA84U46Tv0NCl4FbXyidv/dVUbE3FUUpYpZY4sq8SXLp2bK+5+0YovJtJp0PSBI2kk qMAHaR7Qp/krHGeU2Yclxvl3NYBMQbkbkywixcRvNX2rMikLgI8q57uZijZPPA6ZFrWn FedXe+IERbxoSqcaM7/8xec2KDTxtMsPTyimiyiabzNB1WuapbJFjTWl6Wrw549Mr/4c mpzdnUqlKMWTq5k2hUVN61vkpix79NMW2PgcLkTJdnfsZ3ZIkoph4OdOHsN2oIQnvtXL Zrcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=u4OWc5dBok2on9ln2xrGcVWayGElljcXOJGpihujniA=; b=WzuXvUH5bim5rd3ENPC7CryegONBWqek5Qzagsgi4k94m8NguJw6Qw7tdZR+qMVMac cL5ppkH/pDlbqvugMRCaGu08QGNLZLEjoixIG/2PokP8Sf475iusBlGppyxc7dYyCyJw SLIquaCdrVMLGbxUvTAtEeyRxM5CviVzdzRXE9RCiwvKJ11oydGTyMW5c7X2qy2Hsg4L ekLyoqJKYz10NuonrJGFdXI5X945QFPg9iOToTPE+70OATdbW/MAYeVsWXYhM8J/dxwW okiRbyIim3iIT51l3VtYbIrJ9ePlyt0Kone5sQv66UfVSnWRz48S3x4gwGTzllSJzQs+ nYtg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s186-v6si6829366pfb.39.2018.06.07.08.06.09; Thu, 07 Jun 2018 08:06:25 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936046AbeFGPEK (ORCPT + 99 others); Thu, 7 Jun 2018 11:04:10 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:41566 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936025AbeFGPEE (ORCPT ); Thu, 7 Jun 2018 11:04:04 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbM-0005hO-7g; Thu, 07 Jun 2018 15:09:20 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvbE-0003II-ST; Thu, 07 Jun 2018 15:09:12 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Ursula Braun" , "Julian Wiedmann" , "David S. Miller" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 390/410] s390/qeth: free netdevice when removing a card In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Julian Wiedmann commit 6be687395b3124f002a653c1a50b3260222b3cd7 upstream. On removal, a qeth card's netdevice is currently not properly freed because the call chain looks as follows: qeth_core_remove_device(card) lx_remove_device(card) unregister_netdev(card->dev) card->dev = NULL !!! qeth_core_free_card(card) if (card->dev) !!! free_netdev(card->dev) Fix it by free'ing the netdev straight after unregistering. This also fixes the sysfs-driven layer switch case (qeth_dev_layer2_store()), where the need to free the current netdevice was not considered at all. Note that free_netdev() takes care of the netif_napi_del() for us too. Fixes: 4a71df50047f ("qeth: new qeth device driver") Signed-off-by: Julian Wiedmann Reviewed-by: Ursula Braun Signed-off-by: David S. Miller [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings --- drivers/s390/net/qeth_core_main.c | 2 -- drivers/s390/net/qeth_l2_main.c | 2 +- drivers/s390/net/qeth_l3_main.c | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c @@ -4857,8 +4857,6 @@ static void qeth_core_free_card(struct q QETH_DBF_HEX(SETUP, 2, &card, sizeof(void *)); qeth_clean_channel(&card->read); qeth_clean_channel(&card->write); - if (card->dev) - free_netdev(card->dev); kfree(card->ip_tbd_list); qeth_free_qdio_buffers(card); unregister_service_level(&card->qeth_service_level); --- a/drivers/s390/net/qeth_l2_main.c +++ b/drivers/s390/net/qeth_l2_main.c @@ -922,8 +922,8 @@ static void qeth_l2_remove_device(struct qeth_l2_set_offline(cgdev); if (card->dev) { - netif_napi_del(&card->napi); unregister_netdev(card->dev); + free_netdev(card->dev); card->dev = NULL; } return; --- a/drivers/s390/net/qeth_l3_main.c +++ b/drivers/s390/net/qeth_l3_main.c @@ -3340,8 +3340,8 @@ static void qeth_l3_remove_device(struct qeth_l3_set_offline(cgdev); if (card->dev) { - netif_napi_del(&card->napi); unregister_netdev(card->dev); + free_netdev(card->dev); card->dev = NULL; }