Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9988844ybi; Wed, 24 Jul 2019 13:38:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqkszT2NLvjCc2ZOPsp2hIb4M0jlFenvV9EXqi5vrY5KVxdt5eSbGUagGUcDUny3yzXqOd X-Received: by 2002:a65:4786:: with SMTP id e6mr81094847pgs.448.1564000735777; Wed, 24 Jul 2019 13:38:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564000735; cv=none; d=google.com; s=arc-20160816; b=eQ6Uf3Ob8cpHAVBEfNw3H1qY+UUhRxQ5E9JBaeHavTvkvxBLjixtmDiuBio4tT07i4 p+P7MJuk0I91DUCeqVfLPnC1CgnjYPVzGPICL9KPSrGrxeIizIBNC7uF/xGb9pS3cYLQ 52kP961ReilL3De0k74uARvJQlIuTZwLHIdMLNB23sVecRRew6RLv1uHk1ucY+E0eCVI MBWRx1XhotWp83t18ExL8BV6NozmJ6wAnnwxzU/kQohUmtivVvVQxkTcSBeyjFS8w8Xt l6YHfRGa6B6MAaNqZJK301uKLltXFvAqAptthW3nGKmBfC4fhCINDmgbTlOvzgbIf+e/ Sb9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=icso7ADhznJsMmh4CgYs6vEO8c+aITZHeOSuawjYcgI=; b=cKlw0I1c0t1RTfuQlSPevhywJgDSumVWzJCgdoRA6lAJMOsZBPEqzl/mJDwhBoQeJp 2k/pBCpjag7e7/XRhNwHc4nAatBeOGngPHQWvgnxRnyxAdJwZPTSmorTOkcQrkc0FkYR jgSY7iI8OK/3utYIYiXJQvw9VHvWGszonVpIFXgC3QD5i1JbkLXS2eD5PBdaDo6l3Fvw IP1VF4hiApM7nk47Vnd250TBPzwJbaqxksQJHglOBtycuiS4h0iTzYsANnhUeWFZPV5y nFBx1/+T4K0Jd2fJ38WT4yllXx8wS6ifwCOUpmGVCwZNQzldfPHfqM+kIA30hqtWu64A 8rag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=N9OLhjW8; 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 cd16si14033634plb.72.2019.07.24.13.38.40; Wed, 24 Jul 2019 13:38:55 -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; dkim=pass header.i=@kernel.org header.s=default header.b=N9OLhjW8; 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 S2390903AbfGXUhW (ORCPT + 99 others); Wed, 24 Jul 2019 16:37:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:39826 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387884AbfGXTXy (ORCPT ); Wed, 24 Jul 2019 15:23:54 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 27B4D22AEC; Wed, 24 Jul 2019 19:23:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563996233; bh=bRicMM1vr8NVGXlwayavMoeOg8/keyWSP4QV+K4M610=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N9OLhjW8x5/LoJNi4E5chWvqFodVqZSkyMS4yEDX0tNXQkhM97/0Y/i6EqCdduTXS r13t4dXlnpaR9w1f04LkGcio1+RXDoV2XxJMa01FhCypMZq/lxRvg2omR/CFYmi/+A zqq/C3v59MdPbkSzkemRrJq+tBgZISj+4nidOyfo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Brett Creeley , Anirudh Venkataramanan , Andrew Bowers , Jeff Kirsher , Sasha Levin Subject: [PATCH 5.2 026/413] ice: Gracefully handle reset failure in ice_alloc_vfs() Date: Wed, 24 Jul 2019 21:15:17 +0200 Message-Id: <20190724191737.336085579@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 72f9c2039859e6303550f202d6cc6b8d8af0178c ] Currently if ice_reset_all_vfs() fails in ice_alloc_vfs() we fail to free some resources, reset variables, and return an error value. Fix this by adding another unroll case to free the pf->vf array, set the pf->num_alloc_vfs to 0, and return an error code. Without this, if ice_reset_all_vfs() fails in ice_alloc_vfs() we will not be able to do SRIOV without hard rebooting the system because rmmod'ing the driver does not work. Signed-off-by: Brett Creeley Signed-off-by: Anirudh Venkataramanan Tested-by: Andrew Bowers Signed-off-by: Jeff Kirsher Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c index a805cbdd69be..81ea77978355 100644 --- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c @@ -1134,7 +1134,7 @@ static int ice_alloc_vfs(struct ice_pf *pf, u16 num_alloc_vfs) GFP_KERNEL); if (!vfs) { ret = -ENOMEM; - goto err_unroll_sriov; + goto err_pci_disable_sriov; } pf->vf = vfs; @@ -1154,12 +1154,19 @@ static int ice_alloc_vfs(struct ice_pf *pf, u16 num_alloc_vfs) pf->num_alloc_vfs = num_alloc_vfs; /* VF resources get allocated during reset */ - if (!ice_reset_all_vfs(pf, true)) + if (!ice_reset_all_vfs(pf, true)) { + ret = -EIO; goto err_unroll_sriov; + } goto err_unroll_intr; err_unroll_sriov: + pf->vf = NULL; + devm_kfree(&pf->pdev->dev, vfs); + vfs = NULL; + pf->num_alloc_vfs = 0; +err_pci_disable_sriov: pci_disable_sriov(pf->pdev); err_unroll_intr: /* rearm interrupts here */ -- 2.20.1