* [PATCH] staging: r8188eu: fix memleak in rtw_wx_set_enc_ext
@ 2021-10-19 20:23 Martin Kaiser
2021-11-02 13:31 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Martin Kaiser @ 2021-10-19 20:23 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Larry Finger, Phillip Potter, Michael Straube, linux-staging,
linux-kernel, Martin Kaiser
Free the param struct if the caller sets an unsupported algorithm
and we return an error.
Fixes: 2b42bd58b321 ("staging: r8188eu: introduce new os_dep dir for RTL8188eu driver")
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
drivers/staging/r8188eu/os_dep/ioctl_linux.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
index 4f0ae821d193..4e51d5a55985 100644
--- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
@@ -1897,7 +1897,7 @@ static int rtw_wx_set_enc_ext(struct net_device *dev,
struct ieee_param *param = NULL;
struct iw_point *pencoding = &wrqu->encoding;
struct iw_encode_ext *pext = (struct iw_encode_ext *)extra;
- int ret = 0;
+ int ret = -1;
param_len = sizeof(struct ieee_param) + pext->key_len;
param = kzalloc(param_len, GFP_KERNEL);
@@ -1923,7 +1923,7 @@ static int rtw_wx_set_enc_ext(struct net_device *dev,
alg_name = "CCMP";
break;
default:
- return -1;
+ goto out;
}
strlcpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN);
@@ -1950,6 +1950,7 @@ static int rtw_wx_set_enc_ext(struct net_device *dev,
ret = wpa_set_encryption(dev, param, param_len);
+out:
kfree(param);
return ret;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] staging: r8188eu: fix memleak in rtw_wx_set_enc_ext
2021-10-19 20:23 [PATCH] staging: r8188eu: fix memleak in rtw_wx_set_enc_ext Martin Kaiser
@ 2021-11-02 13:31 ` Dan Carpenter
2021-11-07 14:53 ` Martin Kaiser
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2021-11-02 13:31 UTC (permalink / raw)
To: Martin Kaiser
Cc: Greg Kroah-Hartman, Larry Finger, Phillip Potter, Michael Straube,
linux-staging, linux-kernel
On Tue, Oct 19, 2021 at 10:23:56PM +0200, Martin Kaiser wrote:
> Free the param struct if the caller sets an unsupported algorithm
> and we return an error.
>
> Fixes: 2b42bd58b321 ("staging: r8188eu: introduce new os_dep dir for RTL8188eu driver")
> Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> ---
> drivers/staging/r8188eu/os_dep/ioctl_linux.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> index 4f0ae821d193..4e51d5a55985 100644
> --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> @@ -1897,7 +1897,7 @@ static int rtw_wx_set_enc_ext(struct net_device *dev,
> struct ieee_param *param = NULL;
> struct iw_point *pencoding = &wrqu->encoding;
> struct iw_encode_ext *pext = (struct iw_encode_ext *)extra;
> - int ret = 0;
> + int ret = -1;
>
This was in the original code, so it's fine to leave it as -1, but in
future patches could you change it to -EINVAL instead. (Or don't. I'm
not your boss. I appretiate all the clean up you have done to this
driver).
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] staging: r8188eu: fix memleak in rtw_wx_set_enc_ext
2021-11-02 13:31 ` Dan Carpenter
@ 2021-11-07 14:53 ` Martin Kaiser
0 siblings, 0 replies; 3+ messages in thread
From: Martin Kaiser @ 2021-11-07 14:53 UTC (permalink / raw)
To: Dan Carpenter
Cc: Greg Kroah-Hartman, Larry Finger, Phillip Potter, Michael Straube,
linux-staging, linux-kernel
Thus wrote Dan Carpenter (dan.carpenter@oracle.com):
> On Tue, Oct 19, 2021 at 10:23:56PM +0200, Martin Kaiser wrote:
> > Free the param struct if the caller sets an unsupported algorithm
> > and we return an error.
> > Fixes: 2b42bd58b321 ("staging: r8188eu: introduce new os_dep dir for RTL8188eu driver")
> > Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> > ---
> > drivers/staging/r8188eu/os_dep/ioctl_linux.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> > diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> > index 4f0ae821d193..4e51d5a55985 100644
> > --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> > +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> > @@ -1897,7 +1897,7 @@ static int rtw_wx_set_enc_ext(struct net_device *dev,
> > struct ieee_param *param = NULL;
> > struct iw_point *pencoding = &wrqu->encoding;
> > struct iw_encode_ext *pext = (struct iw_encode_ext *)extra;
> > - int ret = 0;
> > + int ret = -1;
> This was in the original code, so it's fine to leave it as -1, but in
> future patches could you change it to -EINVAL instead. (Or don't. I'm
> not your boss. I appretiate all the clean up you have done to this
> driver).
Thanks.
I tried to change as little as possible to allow for backporting to
stable.
Using a standard error code makes more sense. Some of the ioctl
functions do this already, others use -1. This is something we should
fix when cfg80211 support is in place and we know which of the ioctl
functions survive.
Best regards,
Martin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-11-07 14:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-19 20:23 [PATCH] staging: r8188eu: fix memleak in rtw_wx_set_enc_ext Martin Kaiser
2021-11-02 13:31 ` Dan Carpenter
2021-11-07 14:53 ` Martin Kaiser
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox