Received: by 10.192.165.148 with SMTP id m20csp767264imm; Fri, 27 Apr 2018 07:13:16 -0700 (PDT) X-Google-Smtp-Source: AB8JxZopATNEsoaWJumPXlCO4/Nw/knWxinRCBPx12tIdSiVblVpKNjdF5Eo8gdq9Z9GT7EqljEy X-Received: by 2002:a65:608d:: with SMTP id t13-v6mr2318663pgu.222.1524838396675; Fri, 27 Apr 2018 07:13:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524838396; cv=none; d=google.com; s=arc-20160816; b=Pezl4+ubaeURu+aINSmAkK3dOoPrn/fFlm5gNuaRbn6BTkrpCimhecIIZa4Jx5U9aR AlLxUF8F+/7PAPt18SYbob4NK5YQtncorJlSOqnKcMoZ2pcnQRynUx0MFuKXh2Z6+plt 2/E3sW50X2ujIT3Qu8q0OHHWicayD1zwVM1SBWB5YGRU1R+mFQ9iPMMvA/2ygnuf43MU Xw8RumZV10P2Xj3nphMlPNhG7ikTtD6rN7JbOwrPF8ur0rUMUUFHpRGVdeCLzem2rvLL vRrPfBpKi7GW8g0okQrVjvkqGnBAvFPChw5lqzFuirIuZt60tuQOg9lXEP1FSjx82Wnu MBzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dmarc-filter :arc-authentication-results; bh=9h04DGzb2vPkMIcEr4BlO+dwF9CReu0bthZveG3jG3U=; b=X31cARR9pDVueNjuE0ipvsjNAlpSoDq8XDt38Q0q99sopy2Oo6hOqWLibrTMVberwN 6eQMdwjF07qd/VDanKUPHMYbJj7BnCmP8s4Mbq09P6AOHmQXoRn3serBbW782GNz4965 5VDotW8QmHuc/ppWT0EmjqOKlLxtbyvxvfKhp7LC5rSxF7TyIzeir+E8NZNwW4X7jant d7nvjpry8fundCIXW+iFEj05YuS07VBCdZwOxyB8mNqCvOuxJa0ei28VPQk4indoIyHJ WGWqc5lqhog8wLjc5zN6oCCmCq4wk11pj7NvQf/LSg8nkLm2LH5ZOmxRFgmf/AIEcnxv 7a9Q== 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 m68si1344707pfm.0.2018.04.27.07.13.02; Fri, 27 Apr 2018 07:13:16 -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 S935090AbeD0OLx (ORCPT + 99 others); Fri, 27 Apr 2018 10:11:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:56530 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934628AbeD0OLt (ORCPT ); Fri, 27 Apr 2018 10:11:49 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5C2492189E; Fri, 27 Apr 2018 14:11:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5C2492189E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Arcari , Igor Russkikh , "David S. Miller" Subject: [PATCH 4.16 57/81] net: aquantia: oops when shutdown on already stopped device Date: Fri, 27 Apr 2018 15:58:59 +0200 Message-Id: <20180427135746.588632187@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180427135743.216853156@linuxfoundation.org> References: <20180427135743.216853156@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Igor Russkikh [ Upstream commit 9a11aff25fd43d5bd2660ababdc9f564b0ba183a ] In case netdev is closed at the moment of pci shutdown, aq_nic_stop gets called second time. napi_disable in that case hangs indefinitely. In other case, if device was never opened at all, we get oops because of null pointer access. We should invoke aq_nic_stop conditionally, only if device is running at the moment of shutdown. Reported-by: David Arcari Fixes: 90869ddfefeb ("net: aquantia: Implement pci shutdown callback") Signed-off-by: Igor Russkikh Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/aquantia/atlantic/aq_nic.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c @@ -951,9 +951,11 @@ void aq_nic_shutdown(struct aq_nic_s *se netif_device_detach(self->ndev); - err = aq_nic_stop(self); - if (err < 0) - goto err_exit; + if (netif_running(self->ndev)) { + err = aq_nic_stop(self); + if (err < 0) + goto err_exit; + } aq_nic_deinit(self); err_exit: