The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: Fix error code in chan_alloc_skb_cb()
@ 2025-03-10 19:46 Dan Carpenter
  2025-03-11 15:40 ` patchwork-bot+bluetooth
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2025-03-10 19:46 UTC (permalink / raw)
  To: Jukka Rissanen
  Cc: Marcel Holtmann, Johan Hedberg, Luiz Augusto von Dentz,
	linux-bluetooth, linux-kernel, kernel-janitors

The chan_alloc_skb_cb() function is supposed to return error pointers on
error.  Returning NULL will lead to a NULL dereference.

Fixes: 6b8d4a6a0314 ("Bluetooth: 6LoWPAN: Use connected oriented channel instead of fixed one")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 net/bluetooth/6lowpan.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
index 50cfec8ccac4..3c29778171c5 100644
--- a/net/bluetooth/6lowpan.c
+++ b/net/bluetooth/6lowpan.c
@@ -825,11 +825,16 @@ static struct sk_buff *chan_alloc_skb_cb(struct l2cap_chan *chan,
 					 unsigned long hdr_len,
 					 unsigned long len, int nb)
 {
+	struct sk_buff *skb;
+
 	/* Note that we must allocate using GFP_ATOMIC here as
 	 * this function is called originally from netdev hard xmit
 	 * function in atomic context.
 	 */
-	return bt_skb_alloc(hdr_len + len, GFP_ATOMIC);
+	skb = bt_skb_alloc(hdr_len + len, GFP_ATOMIC);
+	if (!skb)
+		return ERR_PTR(-ENOMEM);
+	return skb;
 }
 
 static void chan_suspend_cb(struct l2cap_chan *chan)
-- 
2.47.2


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

* Re: [PATCH] Bluetooth: Fix error code in chan_alloc_skb_cb()
  2025-03-10 19:46 [PATCH] Bluetooth: Fix error code in chan_alloc_skb_cb() Dan Carpenter
@ 2025-03-11 15:40 ` patchwork-bot+bluetooth
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+bluetooth @ 2025-03-11 15:40 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: jukka.rissanen, marcel, johan.hedberg, luiz.dentz,
	linux-bluetooth, linux-kernel, kernel-janitors

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Mon, 10 Mar 2025 22:46:56 +0300 you wrote:
> The chan_alloc_skb_cb() function is supposed to return error pointers on
> error.  Returning NULL will lead to a NULL dereference.
> 
> Fixes: 6b8d4a6a0314 ("Bluetooth: 6LoWPAN: Use connected oriented channel instead of fixed one")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  net/bluetooth/6lowpan.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)

Here is the summary with links:
  - Bluetooth: Fix error code in chan_alloc_skb_cb()
    https://git.kernel.org/bluetooth/bluetooth-next/c/3144ba2a70e6

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2025-03-11 15:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-10 19:46 [PATCH] Bluetooth: Fix error code in chan_alloc_skb_cb() Dan Carpenter
2025-03-11 15:40 ` patchwork-bot+bluetooth

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