mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] can: etas_es58x: Add check for alloc_can_err_skb
@ 2023-09-01  8:27 Jiasheng Jiang
  2023-09-01 10:53 ` Vincent MAILHOL
  2023-09-01 11:12 ` Denis Kirjanov
  0 siblings, 2 replies; 3+ messages in thread
From: Jiasheng Jiang @ 2023-09-01  8:27 UTC (permalink / raw)
  To: mailhol.vincent, wg, mkl, davem, edumazet, kuba, pabeni,
	arunachalam.santhanam
  Cc: linux-can, netdev, linux-kernel, Jiasheng Jiang

Add check for the return value of alloc_can_err_skb in order to
avoid NULL pointer dereference.

Fixes: 8537257874e9 ("can: etas_es58x: add core support for ETAS ES58X CAN USB interfaces")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 drivers/net/can/usb/etas_es58x/es58x_core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.c b/drivers/net/can/usb/etas_es58x/es58x_core.c
index 0c7f7505632c..d694cb22d9f4 100644
--- a/drivers/net/can/usb/etas_es58x/es58x_core.c
+++ b/drivers/net/can/usb/etas_es58x/es58x_core.c
@@ -680,6 +680,8 @@ int es58x_rx_err_msg(struct net_device *netdev, enum es58x_err error,
 	}
 
 	skb = alloc_can_err_skb(netdev, &cf);
+	if (!skb)
+		return -ENOMEM;
 
 	switch (error) {
 	case ES58X_ERR_OK:	/* 0: No error */
-- 
2.25.1


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

end of thread, other threads:[~2023-09-01 11:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-01  8:27 [PATCH] can: etas_es58x: Add check for alloc_can_err_skb Jiasheng Jiang
2023-09-01 10:53 ` Vincent MAILHOL
2023-09-01 11:12 ` Denis Kirjanov

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

all inboxes | Powered by JetHome®