Skip to content

Commit d848a2d

Browse files
YuuoniySasha Levin
authored andcommitted
crypto: hisilicon/qm - Fix device reference leak in qm_get_qos_value
commit 59b0afd upstream. The qm_get_qos_value() function calls bus_find_device_by_name() which increases the device reference count, but fails to call put_device() to balance the reference count and lead to a device reference leak. Add put_device() calls in both the error path and success path to properly balance the reference count. Found via static analysis. Fixes: 22d7a6c ("crypto: hisilicon/qm - add pci bdf number check") Cc: stable@vger.kernel.org Signed-off-by: Miaoqian Lin <linmq006@gmail.com> Reviewed-by: Longfang Liu <liulongfang@huawei.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 665276c commit d848a2d

File tree

1 file changed

+2
-0
lines changed
  • drivers/crypto/hisilicon

1 file changed

+2
-0
lines changed

drivers/crypto/hisilicon/qm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3857,10 +3857,12 @@ static ssize_t qm_get_qos_value(struct hisi_qm *qm, const char *buf,
38573857
pdev = container_of(dev, struct pci_dev, dev);
38583858
if (pci_physfn(pdev) != qm->pdev) {
38593859
pci_err(qm->pdev, "the pdev input does not match the pf!\n");
3860+
put_device(dev);
38603861
return -EINVAL;
38613862
}
38623863

38633864
*fun_index = pdev->devfn;
3865+
put_device(dev);
38643866

38653867
return 0;
38663868
}

0 commit comments

Comments
 (0)