Netdev List
 help / color / mirror / Atom feed
* [PATCH] net: dsa: fix NULL pointer dereference in seq_match()
@ 2022-11-30  8:44 Yuri Karpov
  2022-11-30 10:07 ` Pavan Chebbi
  2022-11-30 22:01 ` Vladimir Oltean
  0 siblings, 2 replies; 3+ messages in thread
From: Yuri Karpov @ 2022-11-30  8:44 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Yuri Karpov, Florian Fainelli, Vladimir Oltean, David S . Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel,
	lvc-project

ptp_parse_header() result is not checked in seq_match() that can lead
to NULL pointer dereferense.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: c6fe0ad2c349 ("net: dsa: mv88e6xxx: add rx/tx timestamping support")
Signed-off-by: Yuri Karpov <YKarpov@ispras.ru>
---
 drivers/net/dsa/mv88e6xxx/hwtstamp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dsa/mv88e6xxx/hwtstamp.c b/drivers/net/dsa/mv88e6xxx/hwtstamp.c
index 331b4ca089ff..97f30795a2bb 100644
--- a/drivers/net/dsa/mv88e6xxx/hwtstamp.c
+++ b/drivers/net/dsa/mv88e6xxx/hwtstamp.c
@@ -246,7 +246,7 @@ static int seq_match(struct sk_buff *skb, u16 ts_seqid)
 
 	hdr = ptp_parse_header(skb, type);
 
-	return ts_seqid == ntohs(hdr->sequence_id);
+	return hdr ? ts_seqid == ntohs(hdr->sequence_id) : 0;
 }
 
 static void mv88e6xxx_get_rxts(struct mv88e6xxx_chip *chip,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-30 22:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-30  8:44 [PATCH] net: dsa: fix NULL pointer dereference in seq_match() Yuri Karpov
2022-11-30 10:07 ` Pavan Chebbi
2022-11-30 22:01 ` Vladimir Oltean

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox