crypto: nitrox - avoid double free on error path in nitrox_sriov_init()
authorNatalia Petrova <n.petrova@fintech.ru>
Wed, 28 Sep 2022 10:25:05 +0000 (13:25 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:14:21 +0000 (13:14 +0100)
commit9bdf3a59b3dd3e89592f5ad98b958e063388025c
tree67da7354fe9e7d0296704ea5f2e34565e7e526df
parent7efc0d39ee06e9618b894c1888f0b6ec8b0f1bbe
crypto: nitrox - avoid double free on error path in nitrox_sriov_init()

[ Upstream commit 094528b6a5a755b1195a01e10b13597d67d1a0e6 ]

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.

Fixes: 9e5de3e06e54 ("crypto: cavium/nitrox - Add mailbox...")
Signed-off-by: Natalia Petrova <n.petrova@fintech.ru>
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/crypto/cavium/nitrox/nitrox_mbx.c