From: Jiasheng Jiang <jiasheng@iscas.ac.cn>
To: mailhol.vincent@wanadoo.fr, wg@grandegger.com,
mkl@pengutronix.de, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com,
arunachalam.santhanam@in.bosch.com
Cc: linux-can@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
Jiasheng Jiang <jiasheng@iscas.ac.cn>
Subject: [PATCH] can: etas_es58x: Add check for alloc_can_err_skb
Date: Fri, 1 Sep 2023 16:27:55 +0800 [thread overview]
Message-ID: <20230901082755.27104-1-jiasheng@iscas.ac.cn> (raw)
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
next reply other threads:[~2023-09-01 8:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-01 8:27 Jiasheng Jiang [this message]
2023-09-01 10:53 ` [PATCH] can: etas_es58x: Add check for alloc_can_err_skb Vincent MAILHOL
2023-09-01 11:12 ` Denis Kirjanov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230901082755.27104-1-jiasheng@iscas.ac.cn \
--to=jiasheng@iscas.ac.cn \
--cc=arunachalam.santhanam@in.bosch.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mailhol.vincent@wanadoo.fr \
--cc=mkl@pengutronix.de \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=wg@grandegger.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).