Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 50f85e22 authored by Insu Yun's avatar Insu Yun Committed by Kalle Valo
Browse files

mwifiex: correctly handling kzalloc



Since kzalloc can be failed in memory pressure,
it needs to be handled, otherwise NULL dereference could be happened

Signed-off-by: default avatarInsu Yun <wuninsu@gmail.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 9ec855cc
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -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);