* [PATCH] crypto: hisilicon/qm - add missing pci_dev_put() in q_num_set()
@ 2022-11-11 10:00 Xiongfeng Wang
2022-11-14 11:49 ` Weili Qian
2022-11-18 9:17 ` Herbert Xu
0 siblings, 2 replies; 3+ messages in thread
From: Xiongfeng Wang @ 2022-11-11 10:00 UTC (permalink / raw)
To: qianweili, wangzhou1, herbert; +Cc: linux-crypto, wangxiongfeng2, yangyingliang
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.
Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
---
include/linux/hisi_acc_qm.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/include/linux/hisi_acc_qm.h b/include/linux/hisi_acc_qm.h
index e230c7c46110..c3618255b150 100644
--- a/include/linux/hisi_acc_qm.h
+++ b/include/linux/hisi_acc_qm.h
@@ -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",
@@ -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);
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] crypto: hisilicon/qm - add missing pci_dev_put() in q_num_set()
2022-11-11 10:00 [PATCH] crypto: hisilicon/qm - add missing pci_dev_put() in q_num_set() Xiongfeng Wang
@ 2022-11-14 11:49 ` Weili Qian
2022-11-18 9:17 ` Herbert Xu
1 sibling, 0 replies; 3+ messages in thread
From: Weili Qian @ 2022-11-14 11:49 UTC (permalink / raw)
To: Xiongfeng Wang, wangzhou1, herbert; +Cc: linux-crypto, yangyingliang
On 2022/11/11 18:00, Xiongfeng Wang wrote:
> 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.
>
> Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
> ---
> include/linux/hisi_acc_qm.h | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/hisi_acc_qm.h b/include/linux/hisi_acc_qm.h
> index e230c7c46110..c3618255b150 100644
> --- a/include/linux/hisi_acc_qm.h
> +++ b/include/linux/hisi_acc_qm.h
> @@ -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",
> @@ -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);
>
Looks good!
Reviewed-by: Weili Qian <qianweili@huawei.com>
Thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] crypto: hisilicon/qm - add missing pci_dev_put() in q_num_set()
2022-11-11 10:00 [PATCH] crypto: hisilicon/qm - add missing pci_dev_put() in q_num_set() Xiongfeng Wang
2022-11-14 11:49 ` Weili Qian
@ 2022-11-18 9:17 ` Herbert Xu
1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2022-11-18 9:17 UTC (permalink / raw)
To: Xiongfeng Wang; +Cc: qianweili, wangzhou1, linux-crypto, yangyingliang
On Fri, Nov 11, 2022 at 06:00:36PM +0800, Xiongfeng Wang wrote:
> 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.
>
> Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
> ---
> include/linux/hisi_acc_qm.h | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-11-18 9:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-11 10:00 [PATCH] crypto: hisilicon/qm - add missing pci_dev_put() in q_num_set() Xiongfeng Wang
2022-11-14 11:49 ` Weili Qian
2022-11-18 9:17 ` Herbert Xu
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.