Skip to content

Commit

Permalink
powerpc/powernv/sriov: perform null check on iov before dereferencing…
Browse files Browse the repository at this point in the history
… iov

BugLink: https://bugs.launchpad.net/bugs/2034469

[ Upstream commit f4f913c ]

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: 052da31 ("powerpc/powernv/sriov: De-indent setup and teardown")
Signed-off-by: Colin Ian King <[email protected]>
Signed-off-by: Michael Ellerman <[email protected]>
Link: https://msgid.link/[email protected]
Signed-off-by: Sasha Levin <[email protected]>
Signed-off-by: Kamal Mostafa <[email protected]>
Signed-off-by: Stefan Bader <[email protected]>
  • Loading branch information
ColinIanKing authored and roxanan1996 committed Oct 2, 2023
1 parent a9cbbe7 commit ed5e2f7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions arch/powerpc/platforms/powernv/pci-sriov.c
Original file line number Diff line number Diff line change
Expand Up @@ -594,12 +594,12 @@ static void pnv_pci_sriov_disable(struct pci_dev *pdev)
struct pnv_iov_data *iov;

iov = pnv_iov_get(pdev);
num_vfs = iov->num_vfs;
base_pe = iov->vf_pe_arr[0].pe_number;

if (WARN_ON(!iov))
return;

num_vfs = iov->num_vfs;
base_pe = iov->vf_pe_arr[0].pe_number;

/* Release VF PEs */
pnv_ioda_release_vf_PE(pdev);

Expand Down

0 comments on commit ed5e2f7

Please sign in to comment.