linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nitrox: avoid double free on error path in nitrox_sriov_init()
@ 2022-09-28 10:25 Natalia Petrova
  2022-10-21 11:34 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Natalia Petrova @ 2022-09-28 10:25 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller
  Cc: Natalia Petrova, linux-crypto, linux-kernel, ldv-project,
	Alexey Khoroshilov

If alloc_workqueue() fails in nitrox_mbox_init() it deallocates
ndev->iov.vfdev and returns error code, but then nitrox_sriov_init()
calls nitrox_sriov_cleanup() where ndev->iov.vfdev is deallocated
again.

Fix this by nulling ndev->iov.vfdev after the first deallocation.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Natalia Petrova <n.petrova@fintech.ru>
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
 drivers/crypto/cavium/nitrox/nitrox_mbx.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/crypto/cavium/nitrox/nitrox_mbx.c b/drivers/crypto/cavium/nitrox/nitrox_mbx.c
index 9e7308e39b30..d4e06999af9b 100644
--- a/drivers/crypto/cavium/nitrox/nitrox_mbx.c
+++ b/drivers/crypto/cavium/nitrox/nitrox_mbx.c
@@ -195,6 +195,7 @@ int nitrox_mbox_init(struct nitrox_device *ndev)
 	ndev->iov.pf2vf_wq = alloc_workqueue("nitrox_pf2vf", 0, 0);
 	if (!ndev->iov.pf2vf_wq) {
 		kfree(ndev->iov.vfdev);
+		ndev->iov.vfdev = NULL;
 		return -ENOMEM;
 	}
 	/* enable pf2vf mailbox interrupts */
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] nitrox: avoid double free on error path in nitrox_sriov_init()
  2022-09-28 10:25 [PATCH] nitrox: avoid double free on error path in nitrox_sriov_init() Natalia Petrova
@ 2022-10-21 11:34 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2022-10-21 11:34 UTC (permalink / raw)
  To: Natalia Petrova
  Cc: David S. Miller, linux-crypto, linux-kernel, ldv-project,
	Alexey Khoroshilov

On Wed, Sep 28, 2022 at 01:25:05PM +0300, Natalia Petrova wrote:
> If alloc_workqueue() fails in nitrox_mbox_init() it deallocates
> ndev->iov.vfdev and returns error code, but then nitrox_sriov_init()
> calls nitrox_sriov_cleanup() where ndev->iov.vfdev is deallocated
> again.
> 
> Fix this by nulling ndev->iov.vfdev after the first deallocation.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Signed-off-by: Natalia Petrova <n.petrova@fintech.ru>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> ---
>  drivers/crypto/cavium/nitrox/nitrox_mbx.c | 1 +
>  1 file changed, 1 insertion(+)

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] 2+ messages in thread

end of thread, other threads:[~2022-10-21 11:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-28 10:25 [PATCH] nitrox: avoid double free on error path in nitrox_sriov_init() Natalia Petrova
2022-10-21 11:34 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).