Commit cc7710d0 authored by Xiongfeng Wang's avatar Xiongfeng Wang Committed by Herbert Xu

crypto: hisilicon/qm - add missing pci_dev_put() in q_num_set()

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: c8b4b477 ("crypto: hisilicon - add HiSilicon HPRE accelerator")
Signed-off-by: default avatarXiongfeng Wang <wangxiongfeng2@huawei.com>
Reviewed-by: default avatarWeili Qian <qianweili@huawei.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 3a58c231
...@@ -384,14 +384,14 @@ struct hisi_qp { ...@@ -384,14 +384,14 @@ struct hisi_qp {
static inline int q_num_set(const char *val, const struct kernel_param *kp, static inline int q_num_set(const char *val, const struct kernel_param *kp,
unsigned int device) unsigned int device)
{ {
struct pci_dev *pdev = pci_get_device(PCI_VENDOR_ID_HUAWEI, struct pci_dev *pdev;
device, NULL);
u32 n, q_num; u32 n, q_num;
int ret; int ret;
if (!val) if (!val)
return -EINVAL; return -EINVAL;
pdev = pci_get_device(PCI_VENDOR_ID_HUAWEI, device, NULL);
if (!pdev) { if (!pdev) {
q_num = min_t(u32, QM_QNUM_V1, QM_QNUM_V2); q_num = min_t(u32, QM_QNUM_V1, QM_QNUM_V2);
pr_info("No device found currently, suppose queue number is %u\n", pr_info("No device found currently, suppose queue number is %u\n",
...@@ -401,6 +401,8 @@ static inline int q_num_set(const char *val, const struct kernel_param *kp, ...@@ -401,6 +401,8 @@ static inline int q_num_set(const char *val, const struct kernel_param *kp,
q_num = QM_QNUM_V1; q_num = QM_QNUM_V1;
else else
q_num = QM_QNUM_V2; q_num = QM_QNUM_V2;
pci_dev_put(pdev);
} }
ret = kstrtou32(val, 10, &n); ret = kstrtou32(val, 10, &n);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment