From: Wei Yongjun Date: Mon, 3 Dec 2012 15:15:00 +0000 (+0100) Subject: s390/pci: fix potential NULL pointer dereference in dma_free_seg_table() X-Git-Tag: firefly_0821_release~3680^2~1464^2~5 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=bafff1743f2b1bda24daba29c59f755aa2d505b7;p=firefly-linux-kernel-4.4.55.git s390/pci: fix potential NULL pointer dereference in dma_free_seg_table() The dereference to 'zdev' should be moved below the NULL test. Signed-off-by: Wei Yongjun Signed-off-by: Martin Schwidefsky --- diff --git a/arch/s390/pci/pci_dma.c b/arch/s390/pci/pci_dma.c index de48625b3590..c64b4b294b0a 100644 --- a/arch/s390/pci/pci_dma.c +++ b/arch/s390/pci/pci_dma.c @@ -193,12 +193,13 @@ static void dma_free_seg_table(unsigned long entry) static void dma_cleanup_tables(struct zpci_dev *zdev) { - unsigned long *table = zdev->dma_table; + unsigned long *table; int rtx; if (!zdev || !zdev->dma_table) return; + table = zdev->dma_table; for (rtx = 0; rtx < ZPCI_TABLE_ENTRIES; rtx++) if (reg_entry_isvalid(table[rtx])) dma_free_seg_table(table[rtx]);