* [PATCH] mwifiex: correctly handling kzalloc @ 2015-12-29 20:17 Insu Yun [not found] ` <1451420268-15862-1-git-send-email-wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 5+ messages in thread From: Insu Yun @ 2015-12-29 20:17 UTC (permalink / raw) To: akarwar, nishants, kvalo, linux-wireless, netdev, linux-kernel Cc: taesoo, yeongjin.jang, insu, changwoo, Insu Yun 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 ^ permalink raw reply related [flat|nested] 5+ messages in thread
[parent not found: <1451420268-15862-1-git-send-email-wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH] mwifiex: correctly handling kzalloc [not found] ` <1451420268-15862-1-git-send-email-wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2015-12-30 1:37 ` Andy Shevchenko [not found] ` <CAHp75VdZHrXbUytAcXzitH8zzELjimNihG5LfLqX85u4y502SA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 5+ messages in thread From: Andy Shevchenko @ 2015-12-30 1:37 UTC (permalink / raw) To: Insu Yun Cc: akarwar-eYqpPyKDWXRBDgjK7y7TUQ, nishants-eYqpPyKDWXRBDgjK7y7TUQ, Kalle Valo, open list:TI WILINK WIRELES..., netdev, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, taesoo-/4noJB3qBVQ3uPMLIKxrzw, yeongjin.jang-/4noJB3qBVQ3uPMLIKxrzw, insu-/4noJB3qBVQ3uPMLIKxrzw, changwoo-/4noJB3qBVQ3uPMLIKxrzw On Tue, Dec 29, 2015 at 10:17 PM, Insu Yun <wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: Empty commit message? > Signed-off-by: Insu Yun <wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > --- > 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); Just noticed: Looks like good candidate for kcalloc or kmalloc_array, whichever is suitable. > + 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. > + 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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ -- With Best Regards, Andy Shevchenko -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <CAHp75VdZHrXbUytAcXzitH8zzELjimNihG5LfLqX85u4y502SA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH] mwifiex: correctly handling kzalloc [not found] ` <CAHp75VdZHrXbUytAcXzitH8zzELjimNihG5LfLqX85u4y502SA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2015-12-30 14:37 ` Kalle Valo 0 siblings, 0 replies; 5+ messages in thread From: Kalle Valo @ 2015-12-30 14:37 UTC (permalink / raw) To: Andy Shevchenko Cc: Insu Yun, akarwar-eYqpPyKDWXRBDgjK7y7TUQ, nishants-eYqpPyKDWXRBDgjK7y7TUQ, open list:TI WILINK WIRELES..., netdev, linux-kernel@vger.kernel.org, taesoo-/4noJB3qBVQ3uPMLIKxrzw, yeongjin.jang-/4noJB3qBVQ3uPMLIKxrzw, insu-/4noJB3qBVQ3uPMLIKxrzw, changwoo-/4noJB3qBVQ3uPMLIKxrzw Andy Shevchenko <andy.shevchenko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: > On Tue, Dec 29, 2015 at 10:17 PM, Insu Yun <wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 -- Kalle Valo -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] mwifiex: correctly handling kzalloc @ 2015-12-29 19:55 Insu Yun [not found] ` <1451418925-11735-1-git-send-email-wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 5+ messages in thread From: Insu Yun @ 2015-12-29 19:55 UTC (permalink / raw) To: akarwar-eYqpPyKDWXRBDgjK7y7TUQ, nishants-eYqpPyKDWXRBDgjK7y7TUQ, kvalo-sgV2jX0FEOL9JmXXK+q4OQ, linux-wireless-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA Cc: taesoo-/4noJB3qBVQ3uPMLIKxrzw, yeongjin.jang-/4noJB3qBVQ3uPMLIKxrzw, insu-/4noJB3qBVQ3uPMLIKxrzw, changwoo-/4noJB3qBVQ3uPMLIKxrzw, Insu Yun Since kzalloc can be failed in memory pressure, it needs to be handled as above kzalloc. Signed-off-by: Insu Yun <wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- 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); -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 5+ messages in thread
[parent not found: <1451418925-11735-1-git-send-email-wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH] mwifiex: correctly handling kzalloc [not found] ` <1451418925-11735-1-git-send-email-wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2015-12-29 20:09 ` David Miller 0 siblings, 0 replies; 5+ messages in thread From: David Miller @ 2015-12-29 20:09 UTC (permalink / raw) To: wuninsu-Re5JQEeQqe8AvxtiuMwx3w Cc: akarwar-eYqpPyKDWXRBDgjK7y7TUQ, nishants-eYqpPyKDWXRBDgjK7y7TUQ, kvalo-sgV2jX0FEOL9JmXXK+q4OQ, linux-wireless-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, taesoo-/4noJB3qBVQ3uPMLIKxrzw, yeongjin.jang-/4noJB3qBVQ3uPMLIKxrzw, insu-/4noJB3qBVQ3uPMLIKxrzw, changwoo-/4noJB3qBVQ3uPMLIKxrzw From: Insu Yun <wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > --- > 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. -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-12-30 14:37 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-12-29 20:17 [PATCH] mwifiex: correctly handling kzalloc Insu Yun [not found] ` <1451420268-15862-1-git-send-email-wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2015-12-30 1:37 ` Andy Shevchenko [not found] ` <CAHp75VdZHrXbUytAcXzitH8zzELjimNihG5LfLqX85u4y502SA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2015-12-30 14:37 ` Kalle Valo -- strict thread matches above, loose matches on Subject: below -- 2015-12-29 19:55 Insu Yun [not found] ` <1451418925-11735-1-git-send-email-wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2015-12-29 20:09 ` David Miller
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).