@@ -517,6 +517,7 @@ static int ptp_pps_on(struct ptp *ptp, int on, u64 period)
static int ptp_probe(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
+ void __iomem * const *base;
struct ptp *ptp;
int err;
@@ -536,7 +537,15 @@ static int ptp_probe(struct pci_dev *pdev,
if (err)
goto error_free;
- ptp->reg_base = pcim_iomap_table(pdev)[PCI_PTP_BAR_NO];
+ base = pcim_iomap_table(pdev);
+ if (!base)
+ goto error_free;
+
+ ptp->reg_base = base[PCI_PTP_BAR_NO];
+ if (!ptp->reg_base) {
+ err = -ENODEV;
+ goto error_free;
+ }
pci_set_drvdata(pdev, ptp);
if (!first_ptp_block)
Some variable was getting accessed without NULL checks which can lead to pointer exception in some erroneous scenarios. This patch fixes the same by adding the required NULL checks. Fixes: 4086f2a06a35 ("octeontx2-af: Add support for Marvell PTP coprocessor") Signed-off-by: Suman Ghosh <sumang@marvell.com> --- drivers/net/ethernet/marvell/octeontx2/af/ptp.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)