From: Dan Carpenter <dan.carpenter@oracle.com>
To: Yang Yingliang <yangyingliang@huawei.com>
Cc: linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev,
gregkh@linuxfoundation.org, paskripkin@gmail.com
Subject: Re: [PATCH -next 2/3] staging: rtl8192e: rtllib_module: fix error handle case in alloc_rtllib()
Date: Wed, 1 Dec 2021 12:56:02 +0300 [thread overview]
Message-ID: <20211201095602.GB18178@kadam> (raw)
In-Reply-To: <20211201095036.1763163-3-yangyingliang@huawei.com>
Almost perfect, but it needs one minor change.
On Wed, Dec 01, 2021 at 05:50:35PM +0800, Yang Yingliang wrote:
> Some variables are leaked in the error handling in alloc_rtllib(), free
> the variables in the error path.
>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
Please send this as a v4 patch with a little note here:
v4: Fix crypt_info leak
v3: Fix more leaks. Break it up into multple patches.
v2: Make rtllib_softmac_init() return error codes.
You can probably put that in the 0/3 email.
> drivers/staging/rtl8192e/rtllib_module.c | 16 ++++++++++++----
> 1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/rtl8192e/rtllib_module.c b/drivers/staging/rtl8192e/rtllib_module.c
> index 64d9feee1f39..a3c74fa25cfa 100644
> --- a/drivers/staging/rtl8192e/rtllib_module.c
> +++ b/drivers/staging/rtl8192e/rtllib_module.c
> @@ -88,7 +88,7 @@ struct net_device *alloc_rtllib(int sizeof_priv)
> err = rtllib_networks_allocate(ieee);
> if (err) {
> pr_err("Unable to allocate beacon storage: %d\n", err);
> - goto failed;
> + goto free_netdev;
> }
> rtllib_networks_initialize(ieee);
>
> @@ -121,11 +121,13 @@ struct net_device *alloc_rtllib(int sizeof_priv)
> ieee->hwsec_active = 0;
>
> memset(ieee->swcamtable, 0, sizeof(struct sw_cam_table) * 32);
> - rtllib_softmac_init(ieee);
> + err = rtllib_softmac_init(ieee);
> + if (err)
> + goto free_networks;
This needs to free crypt_info; This was my mistake in the email I sent
earlier. Sorry!
>
> ieee->pHTInfo = kzalloc(sizeof(struct rt_hi_throughput), GFP_KERNEL);
> if (!ieee->pHTInfo)
> - return NULL;
> + goto free_softmac;
>
> HTUpdateDefaultSetting(ieee);
> HTInitializeHTInfo(ieee);
> @@ -141,8 +143,14 @@ struct net_device *alloc_rtllib(int sizeof_priv)
>
> return dev;
>
> - failed:
> +free_softmac:
> + rtllib_softmac_free(ieee);
> + lib80211_crypt_info_free(&ieee->crypt_info);
> +free_networks:
> + rtllib_networks_free(ieee);
> +free_netdev:
> free_netdev(dev);
> +
> return NULL;
Something like:
free_softmac:
rtllib_softmac_free(ieee);
free_crypt_info:
lib80211_crypt_info_free(&ieee->crypt_info);
rtllib_networks_free(ieee);
free_netdev:
free_netdev(dev);
regards,
dan carpenter
next prev parent reply other threads:[~2021-12-01 9:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-01 9:50 [PATCH -next 0/3] some fix and cleanup for rtl8192e Yang Yingliang
2021-12-01 9:50 ` [PATCH -next 1/3] staging: rtl8192e: return error code from rtllib_softmac_init() Yang Yingliang
2021-12-01 9:50 ` [PATCH -next 2/3] staging: rtl8192e: rtllib_module: fix error handle case in alloc_rtllib() Yang Yingliang
2021-12-01 9:56 ` Dan Carpenter [this message]
2021-12-02 2:41 ` Yang Yingliang
2021-12-01 9:50 ` [PATCH -next 3/3] staging: rtl8192e: rtllib_module: remove unnecessary assignment Yang Yingliang
2021-12-01 20:15 ` [PATCH -next 0/3] some fix and cleanup for rtl8192e Pavel Skripkin
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=20211201095602.GB18178@kadam \
--to=dan.carpenter@oracle.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=paskripkin@gmail.com \
--cc=yangyingliang@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox