[PATCHv3] staging: rtl8712: Fix freeing ERR_PTR
Gujulan Elango, Hari Prasath (H.)
hgujulan at visteon.com
Thu Apr 30 08:08:30 UTC 2015
The return value of memdup_user is a pointer to errno.Freeing it will cause
error.Hence set it to NULL before branching to free the pointer.smatch also
raises the same warning.
Signed-off-by: Hari Prasath Gujulan Elango <hgujulan at visteon.com>
---
v2:Remove unnecessary goto and return error directly.Use goto
only if some cleanup is done.These were review comments by
Julia Lawall.
v3:Address Dan Carpenter review comments.Send unrelated changes as
seperate patch.
---
drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
index 42fba3f..663f5bd 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
@@ -1905,18 +1905,14 @@ static int r871x_mp_ioctl_hdl(struct net_device *dev,
uint status;
int ret = 0;
- if ((!p->length) || (!p->pointer)) {
- ret = -EINVAL;
- goto _r871x_mp_ioctl_hdl_exit;
- }
+ if ((!p->length) || (!p->pointer))
+ return -EINVAL;
bset = (u8)(p->flags & 0xFFFF);
len = p->length;
pparmbuf = NULL;
pparmbuf = memdup_user(p->pointer, len);
- if (IS_ERR(pparmbuf)) {
- ret = PTR_ERR(pparmbuf);
- goto _r871x_mp_ioctl_hdl_exit;
- }
+ if (IS_ERR(pparmbuf))
+ return PTR_ERR(pparmbuf);
poidparam = (struct mp_ioctl_param *)pparmbuf;
if (poidparam->subcode >= MAX_MP_IOCTL_SUBCODE) {
ret = -EINVAL;
--
1.9.1
More information about the devel
mailing list