* [PATCH] mt76: fix memcpy to potential null pointer on failed allocation
@ 2017-12-14 10:13 Colin King
2017-12-14 10:17 ` Felix Fietkau
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Colin King @ 2017-12-14 10:13 UTC (permalink / raw)
To: Kalle Valo, Matthias Brugger, Lorenzo Bianconi, Felix Fietkau,
linux-wireless, netdev, linux-arm-kernel, linux-mediatek
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Currently if the allocation of skb fails and returns NULL then the
call to skb_put will cause a null pointer dereference. Fix this by
checking for a null skb and returning NULL. Note that calls to
function mt76x2_mcu_msg_alloc don't directly check the null return
but instead pass the NULL pointer to mt76x2_mcu_msg_send which
checks for the NULL and returns ENOMEM in this case.
Detected by CoverityScan, CID#1462624 ("Dereference null return value")
Fixes: 7bc04215a66b ("mt76: add driver code for MT76x2e")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/net/wireless/mediatek/mt76/mt76x2_mcu.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x2_mcu.c
index d45737ee1412..15820b11f9db 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2_mcu.c
@@ -45,6 +45,8 @@ static struct sk_buff *mt76x2_mcu_msg_alloc(const void *data, int len)
struct sk_buff *skb;
skb = alloc_skb(len, GFP_KERNEL);
+ if (!skb)
+ return NULL;
memcpy(skb_put(skb, len), data, len);
return skb;
--
2.14.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mt76: fix memcpy to potential null pointer on failed allocation
2017-12-14 10:13 [PATCH] mt76: fix memcpy to potential null pointer on failed allocation Colin King
@ 2017-12-14 10:17 ` Felix Fietkau
2018-01-08 17:28 ` Kalle Valo
2018-01-08 17:28 ` Kalle Valo
2 siblings, 0 replies; 4+ messages in thread
From: Felix Fietkau @ 2017-12-14 10:17 UTC (permalink / raw)
To: Colin King, Kalle Valo, Matthias Brugger, Lorenzo Bianconi,
linux-wireless, netdev, linux-arm-kernel, linux-mediatek
Cc: kernel-janitors, linux-kernel
On 2017-12-14 11:13, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently if the allocation of skb fails and returns NULL then the
> call to skb_put will cause a null pointer dereference. Fix this by
> checking for a null skb and returning NULL. Note that calls to
> function mt76x2_mcu_msg_alloc don't directly check the null return
> but instead pass the NULL pointer to mt76x2_mcu_msg_send which
> checks for the NULL and returns ENOMEM in this case.
>
> Detected by CoverityScan, CID#1462624 ("Dereference null return value")
>
> Fixes: 7bc04215a66b ("mt76: add driver code for MT76x2e")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Felix Fietkau <nbd@nbd.name>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: mt76: fix memcpy to potential null pointer on failed allocation
2017-12-14 10:13 [PATCH] mt76: fix memcpy to potential null pointer on failed allocation Colin King
2017-12-14 10:17 ` Felix Fietkau
2018-01-08 17:28 ` Kalle Valo
@ 2018-01-08 17:28 ` Kalle Valo
2 siblings, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2018-01-08 17:28 UTC (permalink / raw)
To: Colin Ian King
Cc: Matthias Brugger, Lorenzo Bianconi, Felix Fietkau, linux-wireless,
netdev, linux-arm-kernel, linux-mediatek, kernel-janitors,
linux-kernel
Colin Ian King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently if the allocation of skb fails and returns NULL then the
> call to skb_put will cause a null pointer dereference. Fix this by
> checking for a null skb and returning NULL. Note that calls to
> function mt76x2_mcu_msg_alloc don't directly check the null return
> but instead pass the NULL pointer to mt76x2_mcu_msg_send which
> checks for the NULL and returns ENOMEM in this case.
>
> Detected by CoverityScan, CID#1462624 ("Dereference null return value")
>
> Fixes: 7bc04215a66b ("mt76: add driver code for MT76x2e")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> Acked-by: Felix Fietkau <nbd@nbd.name>
Patch applied to wireless-drivers-next.git, thanks.
364bea50dbea mt76: fix memcpy to potential null pointer on failed allocation
--
https://patchwork.kernel.org/patch/10111747/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: mt76: fix memcpy to potential null pointer on failed allocation
2017-12-14 10:13 [PATCH] mt76: fix memcpy to potential null pointer on failed allocation Colin King
2017-12-14 10:17 ` Felix Fietkau
@ 2018-01-08 17:28 ` Kalle Valo
2018-01-08 17:28 ` Kalle Valo
2 siblings, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2018-01-08 17:28 UTC (permalink / raw)
To: Colin Ian King
Cc: kernel-janitors, netdev, linux-wireless, linux-kernel,
Lorenzo Bianconi, linux-mediatek, Matthias Brugger,
linux-arm-kernel, Felix Fietkau
Colin Ian King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently if the allocation of skb fails and returns NULL then the
> call to skb_put will cause a null pointer dereference. Fix this by
> checking for a null skb and returning NULL. Note that calls to
> function mt76x2_mcu_msg_alloc don't directly check the null return
> but instead pass the NULL pointer to mt76x2_mcu_msg_send which
> checks for the NULL and returns ENOMEM in this case.
>
> Detected by CoverityScan, CID#1462624 ("Dereference null return value")
>
> Fixes: 7bc04215a66b ("mt76: add driver code for MT76x2e")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> Acked-by: Felix Fietkau <nbd@nbd.name>
Patch applied to wireless-drivers-next.git, thanks.
364bea50dbea mt76: fix memcpy to potential null pointer on failed allocation
--
https://patchwork.kernel.org/patch/10111747/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-01-08 17:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-14 10:13 [PATCH] mt76: fix memcpy to potential null pointer on failed allocation Colin King
2017-12-14 10:17 ` Felix Fietkau
2018-01-08 17:28 ` Kalle Valo
2018-01-08 17:28 ` Kalle Valo
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).