All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Yongjun <weiyongjun1@huawei.com>
To: <weiyongjun1@huawei.com>, Kishon Vijay Abraham I <kishon@ti.com>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Bjorn Helgaas <bhelgaas@google.com>
Cc: <linux-pci@vger.kernel.org>, <kernel-janitors@vger.kernel.org>,
	Hulk Robot <hulkci@huawei.com>
Subject: [PATCH -next] PCI: endpoint: Fix missing unlock on error in pci_epf_add_vepf()
Date: Thu, 19 Aug 2021 08:06:55 +0000	[thread overview]
Message-ID: <20210819080655.316468-1-weiyongjun1@huawei.com> (raw)

Add the missing unlock before return from function pci_epf_add_vepf()
in the error handling case.

Fixes: b64215ff2b5e ("PCI: endpoint: Add support to add virtual function in endpoint core")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/pci/endpoint/pci-epf-core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/endpoint/pci-epf-core.c b/drivers/pci/endpoint/pci-epf-core.c
index ec286ee5d04c..8aea16380870 100644
--- a/drivers/pci/endpoint/pci-epf-core.c
+++ b/drivers/pci/endpoint/pci-epf-core.c
@@ -200,8 +200,10 @@ int pci_epf_add_vepf(struct pci_epf *epf_pf, struct pci_epf *epf_vf)
 	mutex_lock(&epf_pf->lock);
 	vfunc_no = find_first_zero_bit(&epf_pf->vfunction_num_map,
 				       BITS_PER_LONG);
-	if (vfunc_no >= BITS_PER_LONG)
+	if (vfunc_no >= BITS_PER_LONG) {
+		mutex_unlock(&epf_pf->lock);
 		return -EINVAL;
+	}
 
 	set_bit(vfunc_no, &epf_pf->vfunction_num_map);
 	epf_vf->vfunc_no = vfunc_no;


             reply	other threads:[~2021-08-19  7:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-19  8:06 Wei Yongjun [this message]
2021-08-19 12:37 ` [PATCH -next] PCI: endpoint: Fix missing unlock on error in pci_epf_add_vepf() Kishon Vijay Abraham I

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210819080655.316468-1-weiyongjun1@huawei.com \
    --to=weiyongjun1@huawei.com \
    --cc=bhelgaas@google.com \
    --cc=hulkci@huawei.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kishon@ti.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.