Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: hisilicon/qm - Fix device reference leak in qm_get_qos_value

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: 22d7a6c39cab ("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>

authored by

Miaoqian Lin and committed by
Herbert Xu
59b0afd0 3c9bf72c

+2
+2
drivers/crypto/hisilicon/qm.c
··· 3871 3871 pdev = container_of(dev, struct pci_dev, dev); 3872 3872 if (pci_physfn(pdev) != qm->pdev) { 3873 3873 pci_err(qm->pdev, "the pdev input does not match the pf!\n"); 3874 + put_device(dev); 3874 3875 return -EINVAL; 3875 3876 } 3876 3877 3877 3878 *fun_index = pdev->devfn; 3879 + put_device(dev); 3878 3880 3879 3881 return 0; 3880 3882 }