Skip to content

Commit

Permalink
ptp: fix NULL pointer dereference in ptp_clock_register
Browse files Browse the repository at this point in the history
Fix NULL pointer dereference in ptp_clock_register. The argument
"parent" of ptp_clock_register may be NULL pointer.

Fixes: 73f3706 ("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>
  • Loading branch information
Yangbo Lu authored and David S. Miller committed Jul 5, 2021
1 parent 6ff63a1 commit 55eac20
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/ptp/ptp_clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 55eac20

Please sign in to comment.