From: Yangbo Lu Date: Mon, 5 Jul 2021 08:53:06 +0000 (+0800) Subject: ptp: fix NULL pointer dereference in ptp_clock_register X-Git-Tag: v5.15~716^2~46 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=55eac20617ca84129273ab248f4d7bfe456967de;p=platform%2Fkernel%2Flinux-starfive.git 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 Signed-off-by: Yangbo Lu Signed-off-by: David S. Miller --- diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c index f012fa5..ce6d9fc 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;