From: Larry Finger <Larry.Finger@lwfinger.net>
To: Christian Engelmayer <cengelma@gmx.at>, devel@driverdev.osuosl.org
Cc: gregkh@linuxfoundation.org, peter.p.waskiewicz.jr@intel.com,
oat.elena@gmail.com, dan.carpenter@oracle.com,
w-lkml@lebenslange-mailadresse.de, teobaluta@gmail.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/5] staging: rtl8188eu: fix potential leak in rtw_wx_read32()
Date: Mon, 28 Apr 2014 22:11:13 -0500 [thread overview]
Message-ID: <535F1851.3020004@lwfinger.net> (raw)
In-Reply-To: <20140428225620.611319cf@spike>
On 04/28/2014 03:56 PM, Christian Engelmayer wrote:
> Function rtw_wx_read32() dynamically allocates a temporary buffer that is not
> freed in all error paths. Use a centralized exit path and make sure that all
> memory is freed correctly. Detected by Coverity - CID 1077711.
>
> Signed-off-by: Christian Engelmayer <cengelma@gmx.at>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
This Ack is valid for all 5 patches.
Larry
> ---
> drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
> index cf30a08..45b47e2 100644
> --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
> +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
> @@ -2154,6 +2154,7 @@ static int rtw_wx_read32(struct net_device *dev,
> u32 bytes;
> u8 *ptmp;
> int rv;
> + int ret = 0;
>
> padapter = (struct adapter *)rtw_netdev_priv(dev);
> p = &wrqu->data;
> @@ -2163,16 +2164,16 @@ static int rtw_wx_read32(struct net_device *dev,
> return -ENOMEM;
>
> if (copy_from_user(ptmp, p->pointer, len)) {
> - kfree(ptmp);
> - return -EFAULT;
> + ret = -EFAULT;
> + goto exit;
> }
>
> bytes = 0;
> addr = 0;
> rv = sscanf(ptmp, "%d,%x", &bytes, &addr);
> if (rv != 2) {
> - kfree(ptmp);
> - return -EINVAL;
> + ret = -EINVAL;
> + goto exit;
> }
>
> switch (bytes) {
> @@ -2190,12 +2191,14 @@ static int rtw_wx_read32(struct net_device *dev,
> break;
> default:
> DBG_88E(KERN_INFO "%s: usage> read [bytes],[address(hex)]\n", __func__);
> - return -EINVAL;
> + ret = -EINVAL;
> + goto exit;
> }
> DBG_88E(KERN_INFO "%s: addr = 0x%08X data =%s\n", __func__, addr, extra);
>
> +exit:
> kfree(ptmp);
> - return 0;
> + return ret;
> }
>
> static int rtw_wx_write32(struct net_device *dev,
>
next prev parent reply other threads:[~2014-04-29 3:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-28 20:54 [PATCH 0/5] staging: rtl8188eu: fix Coverity defects in os_dep/ioctl_linux.c Christian Engelmayer
2014-04-28 20:56 ` [PATCH 1/5] staging: rtl8188eu: fix potential leak in rtw_wx_read32() Christian Engelmayer
2014-04-29 3:11 ` Larry Finger [this message]
2014-04-28 20:57 ` [PATCH 2/5] staging: rtl8188eu: fix potential leak in rtw_wx_set_enc_ext() Christian Engelmayer
2014-04-28 20:59 ` [PATCH 3/5] staging: rtl8188eu: fix potential leak in rtw_mp_QueryDrv() Christian Engelmayer
2014-04-28 21:00 ` [PATCH 4/5] staging: rtl8188eu: fix potential leak in rtw_mp_SetRFPath() Christian Engelmayer
2014-04-28 21:02 ` [PATCH 5/5] staging: rtl8188eu: fix potential leak in rtw_mp_pwrtrk() Christian Engelmayer
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=535F1851.3020004@lwfinger.net \
--to=larry.finger@lwfinger.net \
--cc=cengelma@gmx.at \
--cc=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oat.elena@gmail.com \
--cc=peter.p.waskiewicz.jr@intel.com \
--cc=teobaluta@gmail.com \
--cc=w-lkml@lebenslange-mailadresse.de \
/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
Powered by JetHome