summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYangbo Lu <yangbo.lu@nxp.com>2021-07-05 16:53:06 +0800
committerDavid S. Miller <davem@davemloft.net>2021-07-05 10:09:29 -0700
commit55eac20617ca84129273ab248f4d7bfe456967de (patch)
treec6ec8dedcc5741397c2d076c4753455d180b73be
parent6ff63a150b5556012589ae59efac1b5eeb7d32c3 (diff)
ptp: fix NULL pointer dereference in ptp_clock_register
Fix NULL pointer dereference in ptp_clock_register. The argument "parent" of ptp_clock_register may be NULL pointer. Fixes: 73f37068d540 ("ptp: support ptp physical/virtual clocks conversion") Reported-by: kernel test robot <oliver.sang@intel.com> Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/ptp/ptp_clock.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
index f012fa581cf4..ce6d9fc85607 100644
--- a/drivers/ptp/ptp_clock.c
+++ b/drivers/ptp/ptp_clock.c
@@ -236,7 +236,7 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
}
/* PTP virtual clock is being registered under physical clock */
- if (parent->class && parent->class->name &&
+ if (parent && parent->class && parent->class->name &&
strcmp(parent->class->name, "ptp") == 0)
ptp->is_virtual_clock = true;