From patchwork Mon Nov 27 15:49:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Cassel X-Patchwork-Id: 841737 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.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=linux-pci-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3ylrqZ4mR5z9ryQ for ; Tue, 28 Nov 2017 02:50:50 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752779AbdK0PuK (ORCPT ); Mon, 27 Nov 2017 10:50:10 -0500 Received: from bastet.se.axis.com ([195.60.68.11]:40322 "EHLO bastet.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752663AbdK0PuI (ORCPT ); Mon, 27 Nov 2017 10:50:08 -0500 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id 04D641830E; Mon, 27 Nov 2017 16:50:07 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bastet.se.axis.com Received: from bastet.se.axis.com ([IPv6:::ffff:127.0.0.1]) by localhost (bastet.se.axis.com [::ffff:127.0.0.1]) (amavisd-new, port 10024) with LMTP id 0yMa1IBcbK3h; Mon, 27 Nov 2017 16:50:05 +0100 (CET) Received: from boulder03.se.axis.com (boulder03.se.axis.com [10.0.8.17]) by bastet.se.axis.com (Postfix) with ESMTPS id 207B818330; Mon, 27 Nov 2017 16:50:05 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DD4B81E092; Mon, 27 Nov 2017 16:50:04 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D0AF41E080; Mon, 27 Nov 2017 16:50:04 +0100 (CET) Received: from thoth.se.axis.com (unknown [10.0.2.173]) by boulder03.se.axis.com (Postfix) with ESMTP; Mon, 27 Nov 2017 16:50:04 +0100 (CET) Received: from lnxartpec1.se.axis.com (lnxartpec1.se.axis.com [10.88.4.10]) by thoth.se.axis.com (Postfix) with ESMTP id C3FD71B73; Mon, 27 Nov 2017 16:50:04 +0100 (CET) Received: by lnxartpec1.se.axis.com (Postfix, from userid 20283) id C019840102; Mon, 27 Nov 2017 16:50:04 +0100 (CET) From: Niklas Cassel To: Kishon Vijay Abraham I , Lorenzo Pieralisi , Bjorn Helgaas Cc: Niklas Cassel , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/3] PCI: endpoint: Fix error handling in pci_epc_epf_link() Date: Mon, 27 Nov 2017 16:49:54 +0100 Message-Id: <20171127154955.22214-3-niklas.cassel@axis.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171127154955.22214-1-niklas.cassel@axis.com> References: <20171127154955.22214-1-niklas.cassel@axis.com> X-TM-AS-GCONF: 00 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The error handling in pci_epc_epf_link() was broken, since the clean up code for pci_epc_add_epf() did clear_bit(), even though the matching set_bit() is done after pci_epc_add_epf(). Also, clear_bit() should be done before pci_epc_remove_epf(), since clean up code should normally do things in the reverse order. Fixes: d74679911610 ("PCI: endpoint: Introduce configfs entry for configuring EP functions") Signed-off-by: Niklas Cassel Acked-by: Lorenzo Pieralisi --- drivers/pci/endpoint/pci-ep-cfs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/pci/endpoint/pci-ep-cfs.c b/drivers/pci/endpoint/pci-ep-cfs.c index 4f74386c1ced..e1f5adc9e113 100644 --- a/drivers/pci/endpoint/pci-ep-cfs.c +++ b/drivers/pci/endpoint/pci-ep-cfs.c @@ -106,7 +106,7 @@ static int pci_epc_epf_link(struct config_item *epc_item, epf = epf_group->epf; ret = pci_epc_add_epf(epc, epf); if (ret) - goto err_add_epf; + return ret; func_no = find_first_zero_bit(&epc_group->function_num_map, sizeof(epc_group->function_num_map)); @@ -120,10 +120,8 @@ static int pci_epc_epf_link(struct config_item *epc_item, return 0; err_epf_bind: - pci_epc_remove_epf(epc, epf); - -err_add_epf: clear_bit(func_no, &epc_group->function_num_map); + pci_epc_remove_epf(epc, epf); return ret; }