From: Jes Sorensen <Jes.Sorensen@redhat.com>
To: Benoit Taine <benoit.taine@lip6.fr>
Cc: Larry Finger <Larry.Finger@lwfinger.net>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-wireless@vger.kernel.org, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 9/18] staging: rtl8723au: Use kmemdup instead of kmalloc + memcpy
Date: Mon, 26 May 2014 17:43:45 +0200 [thread overview]
Message-ID: <wrfjy4xo35qm.fsf@ultrasam.lan.trained-monkey.org> (raw)
In-Reply-To: <1401117687-28911-10-git-send-email-benoit.taine@lip6.fr> (Benoit Taine's message of "Mon, 26 May 2014 17:21:18 +0200")
Benoit Taine <benoit.taine@lip6.fr> writes:
> This issue was reported by coccicheck using the semantic patch
> at scripts/coccinelle/api/memdup.cocci
>
> Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
> ---
> Tested by compilation without errors.
>
> drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 3 +--
> drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 16 ++++++----------
> 2 files changed, 7 insertions(+), 12 deletions(-)
Benoit,
I believe this was already applied to staging-next - if you feel
something is missing. Could you please re-diff against the latest
staging-next tree.
Cheers,
Jes
commit 4a6eea4dcbc0328c3126fed264c42b0725bea659
Author: Benoit Taine <benoit.taine@lip6.fr>
Date: Thu May 22 15:08:33 2014 +0200
staging: rtl8723au: Use kmemdup() instead of memcpy() to duplicate memory
This issue was reported by coccicheck using the semantic patch
at scripts/coccinelle/api/memdup.cocci, and tested by compilation.
Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>
> diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
> index e2d426a..f917edd 100644
> --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
> +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
> @@ -339,12 +339,11 @@ int rtl8723a_FirmwareDownload(struct rtw_adapter *padapter)
> rtStatus = _FAIL;
> goto Exit;
> }
> - firmware_buf = kzalloc(fw->size, GFP_KERNEL);
> + firmware_buf = kmemdup(fw->data, fw->size, GFP_KERNEL);
> if (!firmware_buf) {
> rtStatus = _FAIL;
> goto Exit;
> }
> - memcpy(firmware_buf, fw->data, fw->size);
> buf = firmware_buf;
> fw_size = fw->size;
> release_firmware(fw);
> diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
> index 182f57c..735eb99 100644
> --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
> +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
> @@ -1426,14 +1426,13 @@ static int rtw_cfg80211_set_probe_req_wpsp2pie(struct rtw_adapter *padapter,
> pmlmepriv->wps_probe_req_ie = NULL;
> }
>
> - pmlmepriv->wps_probe_req_ie =
> - kmalloc(wps_ielen, GFP_KERNEL);
> + pmlmepriv->wps_probe_req_ie = kmemdup(wps_ie,
> + wps_ielen, GFP_KERNEL);
> if (pmlmepriv->wps_probe_req_ie == NULL) {
> DBG_8723A("%s()-%d: kmalloc() ERROR!\n",
> __func__, __LINE__);
> return -EINVAL;
> }
> - memcpy(pmlmepriv->wps_probe_req_ie, wps_ie, wps_ielen);
> pmlmepriv->wps_probe_req_ie_len = wps_ielen;
> }
> }
> @@ -1697,12 +1696,11 @@ static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie,
> ret = -EINVAL;
> goto exit;
> }
> - buf = kzalloc(ielen, GFP_KERNEL);
> + buf = kmemdup(pie, ielen, GFP_KERNEL);
> if (buf == NULL) {
> ret = -ENOMEM;
> goto exit;
> }
> - memcpy(buf, pie, ielen);
>
> /* dump */
> DBG_8723A("set wpa_ie(length:%zu):\n", ielen);
> @@ -3178,14 +3176,13 @@ static int rtw_cfg80211_set_beacon_wpsp2pie(struct net_device *ndev, char *buf,
> pmlmepriv->wps_beacon_ie = NULL;
> }
>
> - pmlmepriv->wps_beacon_ie =
> - kmalloc(wps_ielen, GFP_KERNEL);
> + pmlmepriv->wps_beacon_ie = kmemdup(wps_ie, wps_ielen,
> + GFP_KERNEL);
> if (pmlmepriv->wps_beacon_ie == NULL) {
> DBG_8723A("%s()-%d: kmalloc() ERROR!\n",
> __func__, __LINE__);
> return -EINVAL;
> }
> - memcpy(pmlmepriv->wps_beacon_ie, wps_ie, wps_ielen);
> pmlmepriv->wps_beacon_ie_len = wps_ielen;
>
> #ifdef CONFIG_8723AU_AP_MODE
> @@ -3270,14 +3267,13 @@ static int rtw_cfg80211_set_assoc_resp_wpsp2pie(struct net_device *net,
> pmlmepriv->wps_assoc_resp_ie = NULL;
> }
>
> - pmlmepriv->wps_assoc_resp_ie = kmalloc(len, GFP_KERNEL);
> + pmlmepriv->wps_assoc_resp_ie = kmemdup(buf, len, GFP_KERNEL);
> if (pmlmepriv->wps_assoc_resp_ie == NULL) {
> DBG_8723A("%s()-%d: kmalloc() ERROR!\n",
> __func__, __LINE__);
> return -EINVAL;
>
> }
> - memcpy(pmlmepriv->wps_assoc_resp_ie, buf, len);
> pmlmepriv->wps_assoc_resp_ie_len = len;
> }
>
next prev parent reply other threads:[~2014-05-26 15:43 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-26 15:21 [PATCH 0/18] " Benoit Taine
2014-05-26 15:21 ` [PATCH 1/18] USB: storage: ene_ub6250: " Benoit Taine
2014-05-26 15:21 ` [PATCH 3/18] VMCI: " Benoit Taine
2014-05-26 15:54 ` walter harms
2014-05-26 15:21 ` [PATCH 2/18] memstick: " Benoit Taine
2014-05-26 15:21 ` [PATCH 4/18] qla4xxx: " Benoit Taine
2014-05-27 8:38 ` Vikas Chaudhary
2014-05-26 15:21 ` [PATCH 5/18] wcn36xx: " Benoit Taine
2014-05-26 15:21 ` [PATCH 6/18] fusion: " Benoit Taine
2014-05-26 15:21 ` [PATCH 7/18] qla2xxx: " Benoit Taine
2014-05-27 5:01 ` Saurav Kashyap
2014-05-26 15:21 ` [PATCH 8/18] Drivers: scsi: " Benoit Taine
2014-05-26 15:21 ` [PATCH 9/18] staging: rtl8723au: " Benoit Taine
2014-05-26 15:43 ` Jes Sorensen [this message]
2014-05-26 15:57 ` Benoit Taine
2014-05-26 15:21 ` [PATCH 10/18] aacraid: " Benoit Taine
2014-05-26 15:21 ` [PATCH 11/18] usb: gadget: " Benoit Taine
2014-05-26 15:21 ` [PATCH 12/18] aic7xxx: " Benoit Taine
2014-05-26 15:21 ` [PATCH 13/18] drm/edid: " Benoit Taine
2014-05-27 6:40 ` Jani Nikula
2014-05-27 15:14 ` Alex Deucher
2014-05-26 15:21 ` [PATCH 14/18] r8152: " Benoit Taine
2014-05-30 23:25 ` David Miller
2014-05-26 15:21 ` [PATCH 15/18] Drivers: media: " Benoit Taine
2014-05-26 15:21 ` [PATCH 16/18] HID: uhid: " Benoit Taine
2014-05-26 15:33 ` David Herrmann
2014-05-26 22:42 ` Jiri Kosina
2014-05-26 15:21 ` [PATCH 17/18] drx-j: " Benoit Taine
2014-05-26 15:21 ` [PATCH 18/18] pinctrl: pinconf-generic: " Benoit Taine
2014-05-27 14:06 ` Linus Walleij
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=wrfjy4xo35qm.fsf@ultrasam.lan.trained-monkey.org \
--to=jes.sorensen@redhat.com \
--cc=Larry.Finger@lwfinger.net \
--cc=benoit.taine@lip6.fr \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
/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
all inboxes | Powered by JetHome®