* [PATCH] mwifiex: check for null return from skb_copy
@ 2019-04-13 16:14 Colin King
2019-04-13 19:27 ` Dan Carpenter
0 siblings, 1 reply; 5+ messages in thread
From: Colin King @ 2019-04-13 16:14 UTC (permalink / raw)
To: Amitkumar Karwar, Nishant Sarmukadam, Ganapathi Bhat, Xinming Hu,
Kalle Valo, David S . Miller, linux-wireless, netdev
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
It is possible for skb_copy to return a null pointer and currently
this will cause a null pointer dereference when the function
mwifiex_uap_queue_bridged_pkt is called. Fix this by checking for
a null return from skb_copy and return -ENOMEM.
Addresses-Coverity: ("Dereference null return")
Fixes: 838e4f449297 ("mwifiex: improve uAP RX handling")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/net/wireless/marvell/mwifiex/uap_txrx.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/wireless/marvell/mwifiex/uap_txrx.c b/drivers/net/wireless/marvell/mwifiex/uap_txrx.c
index 5ce85d5727e4..b262dc78d638 100644
--- a/drivers/net/wireless/marvell/mwifiex/uap_txrx.c
+++ b/drivers/net/wireless/marvell/mwifiex/uap_txrx.c
@@ -256,6 +256,8 @@ int mwifiex_handle_uap_rx_forward(struct mwifiex_private *priv,
if (is_multicast_ether_addr(ra)) {
skb_uap = skb_copy(skb, GFP_ATOMIC);
+ if (!skb_uap)
+ return -ENOMEM;
mwifiex_uap_queue_bridged_pkt(priv, skb_uap);
} else {
if (mwifiex_get_sta_entry(priv, ra)) {
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] mwifiex: check for null return from skb_copy
2019-04-13 16:14 [PATCH] mwifiex: check for null return from skb_copy Colin King
@ 2019-04-13 19:27 ` Dan Carpenter
2019-06-01 17:29 ` [EXT] " Ganapathi Bhat
0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2019-04-13 19:27 UTC (permalink / raw)
To: Colin King
Cc: Amitkumar Karwar, Nishant Sarmukadam, Ganapathi Bhat, Xinming Hu,
Kalle Valo, David S . Miller, linux-wireless, netdev,
kernel-janitors, linux-kernel
On Sat, Apr 13, 2019 at 05:14:38PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> It is possible for skb_copy to return a null pointer and currently
> this will cause a null pointer dereference when the function
> mwifiex_uap_queue_bridged_pkt is called. Fix this by checking for
> a null return from skb_copy and return -ENOMEM.
>
> Addresses-Coverity: ("Dereference null return")
> Fixes: 838e4f449297 ("mwifiex: improve uAP RX handling")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/net/wireless/marvell/mwifiex/uap_txrx.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/wireless/marvell/mwifiex/uap_txrx.c b/drivers/net/wireless/marvell/mwifiex/uap_txrx.c
> index 5ce85d5727e4..b262dc78d638 100644
> --- a/drivers/net/wireless/marvell/mwifiex/uap_txrx.c
> +++ b/drivers/net/wireless/marvell/mwifiex/uap_txrx.c
> @@ -256,6 +256,8 @@ int mwifiex_handle_uap_rx_forward(struct mwifiex_private *priv,
>
> if (is_multicast_ether_addr(ra)) {
> skb_uap = skb_copy(skb, GFP_ATOMIC);
> + if (!skb_uap)
> + return -ENOMEM;
I think we would want to free dev_kfree_skb_any(skb) before returning.
> mwifiex_uap_queue_bridged_pkt(priv, skb_uap);
> } else {
> if (mwifiex_get_sta_entry(priv, ra)) {
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [EXT] Re: [PATCH] mwifiex: check for null return from skb_copy
2019-04-13 19:27 ` Dan Carpenter
@ 2019-06-01 17:29 ` Ganapathi Bhat
2019-06-01 21:08 ` Dan Carpenter
0 siblings, 1 reply; 5+ messages in thread
From: Ganapathi Bhat @ 2019-06-01 17:29 UTC (permalink / raw)
To: Dan Carpenter, Colin King
Cc: Amitkumar Karwar, Nishant Sarmukadam, Xinming Hu, Kalle Valo,
David S . Miller, linux-wireless, netdev, kernel-janitors,
linux-kernel
Hi Dan,
> > if (is_multicast_ether_addr(ra)) {
> > skb_uap = skb_copy(skb, GFP_ATOMIC);
> > + if (!skb_uap)
> > + return -ENOMEM;
>
> I think we would want to free dev_kfree_skb_any(skb) before returning.
I think if the pointer is NULL, no need to free it;
Regards,
Ganapathi
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [EXT] Re: [PATCH] mwifiex: check for null return from skb_copy
2019-06-01 17:29 ` [EXT] " Ganapathi Bhat
@ 2019-06-01 21:08 ` Dan Carpenter
2019-06-02 1:56 ` Ganapathi Bhat
0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2019-06-01 21:08 UTC (permalink / raw)
To: Ganapathi Bhat
Cc: Colin King, Amitkumar Karwar, Nishant Sarmukadam, Xinming Hu,
Kalle Valo, David S . Miller, linux-wireless, netdev,
kernel-janitors, linux-kernel
On Sat, Jun 01, 2019 at 05:29:26PM +0000, Ganapathi Bhat wrote:
> Hi Dan,
>
> > > if (is_multicast_ether_addr(ra)) {
> > > skb_uap = skb_copy(skb, GFP_ATOMIC);
> > > + if (!skb_uap)
> > > + return -ENOMEM;
> >
> > I think we would want to free dev_kfree_skb_any(skb) before returning.
> I think if the pointer is NULL, no need to free it;
You're misreading skb vs skb_uap. "skb_uap" is NULL but "skb" is
non-NULL and I'm pretty sure we should free it.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [EXT] Re: [PATCH] mwifiex: check for null return from skb_copy
2019-06-01 21:08 ` Dan Carpenter
@ 2019-06-02 1:56 ` Ganapathi Bhat
0 siblings, 0 replies; 5+ messages in thread
From: Ganapathi Bhat @ 2019-06-02 1:56 UTC (permalink / raw)
To: Dan Carpenter
Cc: Colin King, Amitkumar Karwar, Nishant Sarmukadam, Xinming Hu,
Kalle Valo, David S . Miller, linux-wireless, netdev,
kernel-janitors, linux-kernel
Hi Dan,
> > > > if (is_multicast_ether_addr(ra)) {
> > > > skb_uap = skb_copy(skb, GFP_ATOMIC);
> > > > + if (!skb_uap)
> > > > + return -ENOMEM;
> > >
> > > I think we would want to free dev_kfree_skb_any(skb) before returning.
> > I think if the pointer is NULL, no need to free it;
>
> You're misreading skb vs skb_uap. "skb_uap" is NULL but "skb" is non-NULL
> and I'm pretty sure we should free it.
Oh, right. I missed it; Yes you are correct.
Regards,
Ganapathi
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-06-02 1:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-13 16:14 [PATCH] mwifiex: check for null return from skb_copy Colin King
2019-04-13 19:27 ` Dan Carpenter
2019-06-01 17:29 ` [EXT] " Ganapathi Bhat
2019-06-01 21:08 ` Dan Carpenter
2019-06-02 1:56 ` Ganapathi Bhat
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).