From patchwork Thu Sep 26 11:29:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 174474 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1921049ill; Thu, 26 Sep 2019 04:31:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqwA8IVeAeEmHnO5COG8c8Kea8bt44XCEQ84GUqRhMLMVmOh2+OgIc3JGWCCP+32YxYqYlwC X-Received: by 2002:aa7:d844:: with SMTP id f4mr2887587eds.269.1569497516439; Thu, 26 Sep 2019 04:31:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569497516; cv=none; d=google.com; s=arc-20160816; b=ytgLl7jDaUTL3GWCLR+cNGcv8bmB5s3sGLzKJrhqRYNcJQfN/aMD15r1nQnC32ASR2 0yZwa7OAi6EMGBEKEQN9LGngoCpLSdW5odPn1F06PfMOMRPnZXG7pX2PAEyf9idvWtKy LccpkoAs/OPwATce4k+wRGJxLVwZAUf0XrFnMSgkzyWFM0X0SMMuDbPbBGlCS6YdZtLt S0wbT8zq8J4ShdfDRxhWJ/6rd7m80CzibbTRlxSvmla87x+Bfd+b3xy6RaVowtpItXHY AS4zXpvigAwnRdy9TWfYvYxpHCPFRwUxjebL2iizf7lcQH3bMD52EMo0us3SgzfUfkkz /JQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=NsBIGvSBpp7lUk2avEDthRUDCLoNlQ7B/MXYwZ1hE5A=; b=KqX9n+QmxuQ1Z009VsPXgniNQ0F39yug7ND0u9hyU6JkLJHF+F3bQ0exLnwj9AJKjQ 15kmvEtm/gOGbZ50EZWobrfKFGjjzIEdX3IIQfrYS5XaXPNGPT1ha61Fx2VYTh71FLMU mH2C6Lum982aZAflZ1lFY0DT+lE0j5KIi4ROaiZ9HfGWUIsDREU18rPqT5FGSPJZDzO/ 889QqFPfzsM9MLH3uSLMPqlfY18y2yQf9ZlNLoNfvAEKFkgYhp3P+WGNjpFB7/cSeumC UFb2mpUcmEnjttP5Yo6kGp/DyaOBoJ+6ZQWXnmwJrMVz8DEHRnM2ydjyTuZ7edn3+A/W lkzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=B5a+RGTk; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k2si1140171ede.311.2019.09.26.04.31.56; Thu, 26 Sep 2019 04:31:56 -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=@ti.com header.s=ti-com-17Q1 header.b=B5a+RGTk; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726823AbfIZLbx (ORCPT + 26 others); Thu, 26 Sep 2019 07:31:53 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:53026 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726014AbfIZLbv (ORCPT ); Thu, 26 Sep 2019 07:31:51 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x8QBVffv016260; Thu, 26 Sep 2019 06:31:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1569497501; bh=NsBIGvSBpp7lUk2avEDthRUDCLoNlQ7B/MXYwZ1hE5A=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=B5a+RGTkuOC1CLJiLCiAVIJcE7HlSJuBgKSlVVgBJZZ5yP3cv1LebqLJhNi3Lb+k3 Fui+vfi4UONozDcjlyXFFY7e42pU3FlxZeeiCLtxe+4GTirYzqRtM8OAwr7o4V/nWT cM89+LDDSawlxV+n6Wny0Grt2E6OKihR6+d40GTM= Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x8QBVfmw050949 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 26 Sep 2019 06:31:41 -0500 Received: from DFLE101.ent.ti.com (10.64.6.22) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Thu, 26 Sep 2019 06:31:33 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE101.ent.ti.com (10.64.6.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Thu, 26 Sep 2019 06:31:40 -0500 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id x8QBUTk9069017; Thu, 26 Sep 2019 06:31:37 -0500 From: Kishon Vijay Abraham I To: Bjorn Helgaas , Jonathan Corbet , Rob Herring , Jon Mason , Dave Jiang , Allen Hubbe , Lorenzo Pieralisi CC: Mark Rutland , , , , , , Subject: [RFC PATCH 16/21] PCI: endpoint: Fix missing mutex_unlock in error case Date: Thu, 26 Sep 2019 16:59:28 +0530 Message-ID: <20190926112933.8922-17-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190926112933.8922-1-kishon@ti.com> References: <20190926112933.8922-1-kishon@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is a missing mutex_unlock() in pci_epc_add_epf() in one of the error scenarios. Fix it here. Signed-off-by: Kishon Vijay Abraham I --- drivers/pci/endpoint/pci-epc-core.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c index 797e5d323998..33c745546a42 100644 --- a/drivers/pci/endpoint/pci-epc-core.c +++ b/drivers/pci/endpoint/pci-epc-core.c @@ -686,6 +686,7 @@ int pci_epc_add_epf(struct pci_epc *epc, struct pci_epf *epf, { struct list_head *list; u32 func_no = 0; + int ret = 0; if (epf->is_vf) return -EINVAL; @@ -705,8 +706,10 @@ int pci_epc_add_epf(struct pci_epc *epc, struct pci_epf *epf, mutex_lock(&epc->lock); func_no = find_first_zero_bit(&epc->function_num_map, BITS_PER_LONG); - if (func_no >= BITS_PER_LONG) - return -EINVAL; + if (func_no >= BITS_PER_LONG) { + ret = -EINVAL; + goto err; + } set_bit(func_no, &epc->function_num_map); if (type == PRIMARY_INTERFACE) { @@ -720,9 +723,11 @@ int pci_epc_add_epf(struct pci_epc *epc, struct pci_epf *epf, } list_add_tail(list, &epc->pci_epf); + +err: mutex_unlock(&epc->lock); - return 0; + return ret; } EXPORT_SYMBOL_GPL(pci_epc_add_epf);