Skip to contentSkip to conversation

mwifiex: correctly handling kzalloc

PATCH Superseded Insu Yun 3 participants 3 messages Dec 29, 2015 – Dec 30, 2015

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Insu Yun

author
#0 lore raw

PATCH 1/1 mwifiex: correctly handling kzalloc

---
 drivers/net/wireless/mwifiex/sdio.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/net/wireless/mwifiex/sdio.c +11 -0
index 78a8474..a8af72d 100644
@@ -2053,8 +2053,19 @@ static int mwifiex_init_sdio(struct mwifiex_adapter *adapter)
 	/* Allocate skb pointer buffers */
 	card->mpa_rx.skb_arr = kzalloc((sizeof(void *)) *
 				       card->mp_agg_pkt_limit, GFP_KERNEL);
+	if (!card->mpa_rx.skb_arr) {
+		kfree(card->mp_regs);
+		return -ENOMEM;
+	}
+
 	card->mpa_rx.len_arr = kzalloc(sizeof(*card->mpa_rx.len_arr) *
 				       card->mp_agg_pkt_limit, GFP_KERNEL);
+	if (!card->mpa_rx.len_arr) {
+		kfree(card->mp_regs);
+		kfree(card->mpa_rx.skb_arr);
+		return -ENOMEM;
+	}
+
 	ret = mwifiex_alloc_sdio_mpa_buffers(adapter,
 					     card->mp_tx_agg_buf_size,
 					     card->mp_rx_agg_buf_size);
Signature · 1 line
1.9.1
#1 lore raw

On Tue, Dec 29, 2015 at 10:17 PM, Insu Yun <[email protected]> wrote:

Empty commit message?

drivers/net/wireless/mwifiex/sdio.c static int mwifiex_init_sdio(struct mwifiex_adapter *adapter) · line 2055

Quoted 13 lines
---
 drivers/net/wireless/mwifiex/sdio.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/net/wireless/mwifiex/sdio.c +0 -0
index 78a8474..a8af72d 100644
@@ -2053,8 +2053,19 @@ static int mwifiex_init_sdio(struct mwifiex_adapter *adapter)
        /* Allocate skb pointer buffers */
        card->mpa_rx.skb_arr = kzalloc((sizeof(void *)) *
                                       card->mp_agg_pkt_limit, GFP_KERNEL);

Just noticed: Looks like good candidate for kcalloc or kmalloc_array, whichever is suitable.

drivers/net/wireless/mwifiex/sdio.c static int mwifiex_init_sdio(struct mwifiex_adapter *adapter) · line 2062

Quoted 7 lines
drivers/net/wireless/mwifiex/sdio.c +5 -0
+       if (!card->mpa_rx.skb_arr) {
+               kfree(card->mp_regs);
+               return -ENOMEM;
+       }
+
        card->mpa_rx.len_arr = kzalloc(sizeof(*card->mpa_rx.len_arr) *
                                       card->mp_agg_pkt_limit, GFP_KERNEL);

Ditto.

Quoted 19 lines
drivers/net/wireless/mwifiex/sdio.c +6 -0
+       if (!card->mpa_rx.len_arr) {
+               kfree(card->mp_regs);
+               kfree(card->mpa_rx.skb_arr);
 
 
+               return -ENOMEM;
+       }
+
        ret = mwifiex_alloc_sdio_mpa_buffers(adapter,
                                             card->mp_tx_agg_buf_size,
                                             card->mp_rx_agg_buf_size);

--
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 6 lines
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
Quoted 3 lines · Andy Shevchenko

On Tue, Dec 29, 2015 at 10:17 PM, Insu Yun <[email protected]> wrote:

Empty commit message?

Yeah, no empty commit log, please.

And then you submit a new version remember to add v2, v3 and so on:

http://kernelnewbies.org/FirstKernelPatch#head-5c81b3c517a1d0bbc24f92594cb734e155fcbbcb

Signature · 5 lines
Kalle Valo
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html