]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
powerpc/powernv/sriov: perform null check on iov before dereferencing iov
authorColin Ian King <colin.i.king@gmail.com>
Thu, 8 Jun 2023 09:58:49 +0000 (10:58 +0100)
committerRoxana Nicolescu <roxana.nicolescu@canonical.com>
Mon, 2 Oct 2023 15:19:50 +0000 (17:19 +0200)
commited5e2f7730589e581cd82639877bc10ade87fcfe
tree9b2275964a9765b202dcad891dcd323648a0b13b
parenta9cbbe71231650cc94b6738580eb03f01fb61585
powerpc/powernv/sriov: perform null check on iov before dereferencing iov

BugLink: https://bugs.launchpad.net/bugs/2034469
[ Upstream commit f4f913c980bc6abe0ccfe88fe3909c125afe4a2d ]

Currently pointer iov is being dereferenced before the null check of iov
which can lead to null pointer dereference errors. Fix this by moving the
iov null check before the dereferencing.

Detected using cppcheck static analysis:
linux/arch/powerpc/platforms/powernv/pci-sriov.c:597:12: warning: Either
the condition '!iov' is redundant or there is possible null pointer
dereference: iov. [nullPointerRedundantCheck]
 num_vfs = iov->num_vfs;
           ^

Fixes: 052da31d45fc ("powerpc/powernv/sriov: De-indent setup and teardown")
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20230608095849.1147969-1-colin.i.king@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
arch/powerpc/platforms/powernv/pci-sriov.c