Skip to content

Commit

Permalink
crypto: hisilicon/qm - add missing pci_dev_put() in q_num_set()
Browse files Browse the repository at this point in the history
pci_get_device() will increase the reference count for the returned
pci_dev. We need to use pci_dev_put() to decrease the reference count
before q_num_set() returns.

Fixes: c8b4b47 ("crypto: hisilicon - add HiSilicon HPRE accelerator")
Signed-off-by: Xiongfeng Wang <[email protected]>
Reviewed-by: Weili Qian <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
fenghusthu authored and herbertx committed Nov 18, 2022
1 parent 3a58c23 commit cc7710d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions include/linux/hisi_acc_qm.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,14 +384,14 @@ struct hisi_qp {
static inline int q_num_set(const char *val, const struct kernel_param *kp,
unsigned int device)
{
struct pci_dev *pdev = pci_get_device(PCI_VENDOR_ID_HUAWEI,
device, NULL);
struct pci_dev *pdev;
u32 n, q_num;
int ret;

if (!val)
return -EINVAL;

pdev = pci_get_device(PCI_VENDOR_ID_HUAWEI, device, NULL);
if (!pdev) {
q_num = min_t(u32, QM_QNUM_V1, QM_QNUM_V2);
pr_info("No device found currently, suppose queue number is %u\n",
Expand All @@ -401,6 +401,8 @@ static inline int q_num_set(const char *val, const struct kernel_param *kp,
q_num = QM_QNUM_V1;
else
q_num = QM_QNUM_V2;

pci_dev_put(pdev);
}

ret = kstrtou32(val, 10, &n);
Expand Down

0 comments on commit cc7710d

Please sign in to comment.