From: Ji-Hun Kim <ji_hun.kim@samsung.com>
To: Jia-Ju Bai <baijiaju1990@gmail.com>
Cc: gregkh@linuxfoundation.org, forest@alittletooquiet.net,
dartnorris@gmail.com, santhameena13@gmail.com,
julia.lawall@lip6.fr, y.k.oh@samsung.com,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH v3] staging: vt6655: check for memory allocation failures
Date: Fri, 30 Mar 2018 03:50:03 +0000 [thread overview]
Message-ID: <20180330035003.GA27619@ubuntu> (raw)
In-Reply-To: <be23acda-38c0-dce3-9c79-8672113f6960@gmail.com>
On Fri, Mar 30, 2018 at 11:15:03AM +0800, Jia-Ju Bai wrote:
>
>
> On 2018/3/30 10:44, Ji-Hun Kim wrote:
> >@@ -1165,10 +1205,18 @@ static int vnt_start(struct ieee80211_hw *hw)
> > }
> > dev_dbg(&priv->pcid->dev, "call device init rd0 ring\n");
> >- device_init_rd0_ring(priv);
> >- device_init_rd1_ring(priv);
> >- device_init_td0_ring(priv);
> >- device_init_td1_ring(priv);
> >+ ret = device_init_rd0_ring(priv);
> >+ if (ret)
> >+ goto error;
> >+ ret = device_init_rd1_ring(priv);
> >+ if (ret)
> >+ goto error;
> >+ ret = device_init_td0_ring(priv);
> >+ if (ret)
> >+ goto error;
> >+ ret = device_init_td1_ring(priv);
> >+ if (ret)
> >+ goto error;
> > device_init_registers(priv);
> >@@ -1178,6 +1226,8 @@ static int vnt_start(struct ieee80211_hw *hw)
> > ieee80211_wake_queues(hw);
> > return 0;
> >+error:
> >+ return ret;
> > }
>
> This code will lead to memory leaks when device_init_rd1_ring()
> fails, because the memory allocated by device_init_rd0_ring() is not
> freed.
>
> I think this one will be better:
> ret = device_init_rd0_ring(priv);
> if (ret)
> goto error_init_rd0_ring;
> ret = device_init_rd1_ring(priv);
> if (ret)
> goto error_init_rd1_ring;
> ret = device_init_td0_ring(priv);
> if (ret)
> goto error_init_td0_ring;
> ret = device_init_td1_ring(priv);
> if (ret)
> goto error_init_td1_ring;
> ......
> error_init_td1_ring:
> device_free_td0_ring(priv);
> error_init_td0_ring:
> device_free_rd1_ring(priv);
> error_init_rd1_ring:
> device_free_rd0_ring(priv);
> error_init_rd0_ring:
> return ret;
>
>
> Best wishes,
> Jia-Ju Bai
>
>
Oh, sorry, I got what you said. Yes, you are right. I am going to make patch v4. Thanks!
Best regards,
Ji-Hun
WARNING: multiple messages have this Message-ID (diff)
From: Ji-Hun Kim <ji_hun.kim@samsung.com>
To: Jia-Ju Bai <baijiaju1990@gmail.com>
Cc: gregkh@linuxfoundation.org, forest@alittletooquiet.net,
dartnorris@gmail.com, santhameena13@gmail.com,
julia.lawall@lip6.fr, y.k.oh@samsung.com,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH v3] staging: vt6655: check for memory allocation failures
Date: Fri, 30 Mar 2018 12:50:03 +0900 [thread overview]
Message-ID: <20180330035003.GA27619@ubuntu> (raw)
In-Reply-To: <be23acda-38c0-dce3-9c79-8672113f6960@gmail.com>
On Fri, Mar 30, 2018 at 11:15:03AM +0800, Jia-Ju Bai wrote:
>
>
> On 2018/3/30 10:44, Ji-Hun Kim wrote:
> >@@ -1165,10 +1205,18 @@ static int vnt_start(struct ieee80211_hw *hw)
> > }
> > dev_dbg(&priv->pcid->dev, "call device init rd0 ring\n");
> >- device_init_rd0_ring(priv);
> >- device_init_rd1_ring(priv);
> >- device_init_td0_ring(priv);
> >- device_init_td1_ring(priv);
> >+ ret = device_init_rd0_ring(priv);
> >+ if (ret)
> >+ goto error;
> >+ ret = device_init_rd1_ring(priv);
> >+ if (ret)
> >+ goto error;
> >+ ret = device_init_td0_ring(priv);
> >+ if (ret)
> >+ goto error;
> >+ ret = device_init_td1_ring(priv);
> >+ if (ret)
> >+ goto error;
> > device_init_registers(priv);
> >@@ -1178,6 +1226,8 @@ static int vnt_start(struct ieee80211_hw *hw)
> > ieee80211_wake_queues(hw);
> > return 0;
> >+error:
> >+ return ret;
> > }
>
> This code will lead to memory leaks when device_init_rd1_ring()
> fails, because the memory allocated by device_init_rd0_ring() is not
> freed.
>
> I think this one will be better:
> ret = device_init_rd0_ring(priv);
> if (ret)
> goto error_init_rd0_ring;
> ret = device_init_rd1_ring(priv);
> if (ret)
> goto error_init_rd1_ring;
> ret = device_init_td0_ring(priv);
> if (ret)
> goto error_init_td0_ring;
> ret = device_init_td1_ring(priv);
> if (ret)
> goto error_init_td1_ring;
> ......
> error_init_td1_ring:
> device_free_td0_ring(priv);
> error_init_td0_ring:
> device_free_rd1_ring(priv);
> error_init_rd1_ring:
> device_free_rd0_ring(priv);
> error_init_rd0_ring:
> return ret;
>
>
> Best wishes,
> Jia-Ju Bai
>
>
Oh, sorry, I got what you said. Yes, you are right. I am going to make patch v4. Thanks!
Best regards,
Ji-Hun
next prev parent reply other threads:[~2018-03-30 3:50 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20180330024416epcas2p2f566f43a8f5af8b4ebc17659e3cf0ecf@epcas2p2.samsung.com>
2018-03-30 2:44 ` [PATCH v3] staging: vt6655: check for memory allocation failures Ji-Hun Kim
2018-03-30 2:44 ` Ji-Hun Kim
2018-03-30 3:15 ` Jia-Ju Bai
2018-03-30 3:15 ` Jia-Ju Bai
2018-03-30 3:39 ` Ji-Hun Kim
2018-03-30 3:39 ` Ji-Hun Kim
2018-03-30 3:50 ` Jia-Ju Bai
2018-03-30 3:50 ` Jia-Ju Bai
2018-03-30 3:50 ` Ji-Hun Kim [this message]
2018-03-30 3:50 ` Ji-Hun Kim
2018-04-03 10:40 ` Dan Carpenter
2018-04-03 10:40 ` Dan Carpenter
2018-04-04 7:24 ` Ji-Hun Kim
2018-04-04 7:24 ` Ji-Hun Kim
2018-04-04 9:53 ` Dan Carpenter
2018-04-04 9:53 ` Dan Carpenter
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=20180330035003.GA27619@ubuntu \
--to=ji_hun.kim@samsung.com \
--cc=baijiaju1990@gmail.com \
--cc=dartnorris@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=forest@alittletooquiet.net \
--cc=gregkh@linuxfoundation.org \
--cc=julia.lawall@lip6.fr \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=santhameena13@gmail.com \
--cc=y.k.oh@samsung.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.