[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210705085306.15470-1-yangbo.lu@nxp.com>
Date: Mon, 5 Jul 2021 16:53:06 +0800
From: Yangbo Lu <yangbo.lu@....com>
To: netdev@...r.kernel.org
Cc: Yangbo Lu <yangbo.lu@....com>, linux-kernel@...r.kernel.org,
Richard Cochran <richardcochran@...il.com>,
"David S . Miller" <davem@...emloft.net>,
Rui Sousa <rui.sousa@....com>,
Sebastien Laveze <sebastien.laveze@....com>
Subject: [net] 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@...el.com>
Signed-off-by: Yangbo Lu <yangbo.lu@....com>
---
drivers/ptp/ptp_clock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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;
base-commit: 6ff63a150b5556012589ae59efac1b5eeb7d32c3
--
2.25.1
Powered by blists - more mailing lists