Skip to content

Commit d9a1aae

Browse files
ColinIanKinggregkh
authored andcommitted
powerpc/powernv/sriov: perform null check on iov before dereferencing iov
[ 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 <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>
1 parent 0af388f commit d9a1aae

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

arch/powerpc/platforms/powernv/pci-sriov.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,12 +594,12 @@ static void pnv_pci_sriov_disable(struct pci_dev *pdev)
594594
struct pnv_iov_data *iov;
595595

596596
iov = pnv_iov_get(pdev);
597-
num_vfs = iov->num_vfs;
598-
base_pe = iov->vf_pe_arr[0].pe_number;
599-
600597
if (WARN_ON(!iov))
601598
return;
602599

600+
num_vfs = iov->num_vfs;
601+
base_pe = iov->vf_pe_arr[0].pe_number;
602+
603603
/* Release VF PEs */
604604
pnv_ioda_release_vf_PE(pdev);
605605

0 commit comments

Comments
 (0)