[PATCH] staging: vt6655: don't leak when returning -EOPNOTSUPP in vt6655_hostap_ioctl

2013-09-30 Thread Jesper Juhl
Make sure we always free(param); and remove a redundant "goto out;"
just before we'll hit the label anyway.

Signed-off-by: Jesper Juhl 
---
 drivers/staging/vt6655/hostap.c |   25 ++---
 1 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
index 8acff44..fdd63b6 100644
--- a/drivers/staging/vt6655/hostap.c
+++ b/drivers/staging/vt6655/hostap.c
@@ -720,7 +720,6 @@ static int hostap_get_encryption(PSDevice pDevice,
  * Return Value:
  *
  */
-
 int vt6655_hostap_ioctl(PSDevice pDevice, struct iw_point *p)
 {
struct viawget_hostapd_param *param;
@@ -755,8 +754,8 @@ int vt6655_hostap_ioctl(PSDevice pDevice, struct iw_point 
*p)
break;
case VIAWGET_HOSTAPD_SET_ASSOC_AP_ADDR:
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO 
"VIAWGET_HOSTAPD_SET_ASSOC_AP_ADDR \n");
-   return -EOPNOTSUPP;
-   break;
+   ret = -EOPNOTSUPP;
+   goto out;
case VIAWGET_HOSTAPD_FLUSH:
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_FLUSH \n");
spin_lock_irq(&pDevice->lock);
@@ -790,40 +789,36 @@ int vt6655_hostap_ioctl(PSDevice pDevice, struct iw_point 
*p)
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO 
"VIAWGET_HOSTAPD_SET_FLAGS_STA \n");
ret = hostap_set_flags_sta(pDevice, param);
break;
-
case VIAWGET_HOSTAPD_MLME:
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_MLME \n");
-   return -EOPNOTSUPP;
-
+   ret = -EOPNOTSUPP;
+   goto out;
case VIAWGET_HOSTAPD_SET_GENERIC_ELEMENT:
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO 
"VIAWGET_HOSTAPD_SET_GENERIC_ELEMENT \n");
ret = hostap_set_generic_element(pDevice, param);
break;
-
case VIAWGET_HOSTAPD_SCAN_REQ:
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SCAN_REQ 
\n");
-   return -EOPNOTSUPP;
-
+   ret = -EOPNOTSUPP;
+   goto out;
case VIAWGET_HOSTAPD_STA_CLEAR_STATS:
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO 
"VIAWGET_HOSTAPD_STA_CLEAR_STATS \n");
-   return -EOPNOTSUPP;
-
+   ret = -EOPNOTSUPP;
+   goto out;
default:
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "vt6655_hostap_ioctl: 
unknown cmd=%d\n",
(int)param->cmd);
-   return -EOPNOTSUPP;
-   break;
+   ret = -EOPNOTSUPP;
+   goto out;
}
 
if ((ret == 0) && ap_ioctl) {
if (copy_to_user(p->pointer, param, p->length)) {
ret = -EFAULT;
-       goto out;
}
}
 
 out:
kfree(param);
-
return ret;
 }
-- 
1.7.1


-- 
Jesper Juhlhttp://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: lustre: Don't leak 'buffer' in cfs_get_environ()

2013-09-30 Thread Jesper Juhl
If 'down_read_trylock' fails we'll curently leak the memory allocated to 
'buffer'.
Fix the leak by simply kfree'ing 'buffer' before returning '-EDEADLK'.

Signed-off-by: Jesper Juhl 
---
 .../lustre/lustre/libcfs/linux/linux-curproc.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c 
b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c
index ea9e949..ecd031f 100644
--- a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c
+++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c
@@ -227,8 +227,10 @@ int cfs_get_environ(const char *key, char *value, int 
*val_len)
 * which is already holding mmap_sem for writes.  If some other
 * thread gets the write lock in the meantime, this thread will
 * block, but at least it won't deadlock on itself.  LU-1735 */
-   if (down_read_trylock(&mm->mmap_sem) == 0)
+   if (down_read_trylock(&mm->mmap_sem) == 0) {
+   kfree(buffer);
return -EDEADLK;
+   }
up_read(&mm->mmap_sem);
 
addr = mm->env_start;
-- 
1.7.1


-- 
Jesper Juhlhttp://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel