Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1299412 > unrolled thread

[PATCH v2] mwifiex: correctly handling kzalloc

Started byInsu Yun <wuninsu@gmail.com>
First post2015-12-30 17:00 +0100
Last post2015-12-30 17:00 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH v2] mwifiex: correctly handling kzalloc Insu Yun <wuninsu@gmail.com> - 2015-12-30 17:00 +0100

#1299412 — [PATCH v2] mwifiex: correctly handling kzalloc

FromInsu Yun <wuninsu@gmail.com>
Date2015-12-30 17:00 +0100
Subject[PATCH v2] mwifiex: correctly handling kzalloc
Message-ID<qLrkm-61-5@gated-at.bofh.it>
Since kzalloc can be failed in memory pressure,
it needs to be handled, otherwise NULL dereference could be happened

Signed-off-by: Insu Yun <wuninsu@gmail.com>
---
 drivers/net/wireless/mwifiex/sdio.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/net/wireless/mwifiex/sdio.c b/drivers/net/wireless/mwifiex/sdio.c
index 78a8474..a8af72d 100644
--- a/drivers/net/wireless/mwifiex/sdio.c
+++ b/drivers/net/wireless/mwifiex/sdio.c
@@ -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);
-- 
1.9.1

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

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web