From: David Miller <davem@davemloft.net>
To: wuninsu@gmail.com
Cc: akarwar@marvell.com, nishants@marvell.com, kvalo@codeaurora.org,
linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, taesoo@gatech.edu,
yeongjin.jang@gatech.edu, insu@gatech.edu, changwoo@gatech.edu
Subject: Re: [PATCH] mwifiex: correctly handling kzalloc
Date: Tue, 29 Dec 2015 15:09:28 -0500 (EST) [thread overview]
Message-ID: <20151229.150928.1955323552394590874.davem@davemloft.net> (raw)
In-Reply-To: <1451418925-11735-1-git-send-email-wuninsu@gmail.com>
From: Insu Yun <wuninsu@gmail.com>
Date: Tue, 29 Dec 2015 14:55:25 -0500
> Since kzalloc can be failed in memory pressure,
> it needs to be handled as above kzalloc.
>
> Signed-off-by: Insu Yun <wuninsu@gmail.com>
> ---
> drivers/net/wireless/mwifiex/sdio.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/net/wireless/mwifiex/sdio.c b/drivers/net/wireless/mwifiex/sdio.c
> index 78a8474..d114934 100644
> --- a/drivers/net/wireless/mwifiex/sdio.c
> +++ b/drivers/net/wireless/mwifiex/sdio.c
> @@ -2053,8 +2053,14 @@ 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)
> + 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)
> + return -ENOMEM;
> +
> ret = mwifiex_alloc_sdio_mpa_buffers(adapter,
> card->mp_tx_agg_buf_size,
> card->mp_rx_agg_buf_size);
You can't just return, you have to release all of the resources
acquired above the point where the error happens.
next prev parent reply other threads:[~2015-12-29 20:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-29 19:55 [PATCH] mwifiex: correctly handling kzalloc Insu Yun
2015-12-29 20:09 ` David Miller [this message]
-- strict thread matches above, loose matches on Subject: below --
2015-12-29 20:17 Insu Yun
2015-12-30 1:37 ` Andy Shevchenko
2015-12-30 14:37 ` Kalle Valo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151229.150928.1955323552394590874.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=akarwar@marvell.com \
--cc=changwoo@gatech.edu \
--cc=insu@gatech.edu \
--cc=kvalo@codeaurora.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nishants@marvell.com \
--cc=taesoo@gatech.edu \
--cc=wuninsu@gmail.com \
--cc=yeongjin.jang@gatech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox