public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [2.4] Fix memleak on error exit path in sk98 driver.
@ 2003-09-21 11:45 Oleg Drokin
  2003-09-21 14:14 ` Mirko Lindner
  0 siblings, 1 reply; 2+ messages in thread
From: Oleg Drokin @ 2003-09-21 11:45 UTC (permalink / raw)
  To: marcelo, linux-kernel; +Cc: mlindner

Hello!

   There is a trivial memleak in sk98 ioctl handling routinue,
   the patch is also trivial. Please apply.
   Found with help of smatch.

===== drivers/net/sk98lin/skge.c 1.14 vs edited =====
--- 1.14/drivers/net/sk98lin/skge.c	Wed Sep  3 21:15:10 2003
+++ edited/drivers/net/sk98lin/skge.c	Sun Sep 21 15:38:01 2003
@@ -3616,20 +3616,21 @@
 			Length = sizeof(pAC->PnmiStruct) + HeaderLength;
 		}
 		if (NULL == (pMemBuf = kmalloc(Length, GFP_KERNEL))) {
-			return -EFAULT;
+			return -ENOMEM;
 		}
 		if(copy_from_user(pMemBuf, Ioctl.pData, Length)) {
-			return -EFAULT;
+			goto fault;
 		}
 		if ((Ret = SkPnmiGenIoctl(pAC, pAC->IoBase, pMemBuf, &Length, 0)) < 0) {
-			return -EFAULT;
+			goto fault;
 		}
 		if(copy_to_user(Ioctl.pData, pMemBuf, Length) ) {
-			return -EFAULT;
+			goto fault;
 		}
 		Ioctl.Len = Length;
 		if(copy_to_user(rq->ifr_data, &Ioctl, sizeof(SK_GE_IOCTL))) {
-			return -EFAULT;
+fault:
+			Err = -EFAULT;
 		}
 		kfree(pMemBuf); /* cleanup everything */
 		break;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] [2.4] Fix memleak on error exit path in sk98 driver.
  2003-09-21 11:45 [PATCH] [2.4] Fix memleak on error exit path in sk98 driver Oleg Drokin
@ 2003-09-21 14:14 ` Mirko Lindner
  0 siblings, 0 replies; 2+ messages in thread
From: Mirko Lindner @ 2003-09-21 14:14 UTC (permalink / raw)
  To: Oleg Drokin; +Cc: marcelo, linux-kernel, mlindner

Thank you. Will be done tomorrow.

Cheers,

Mirko


Oleg Drokin schrieb:
> Hello!
> 
>    There is a trivial memleak in sk98 ioctl handling routinue,
>    the patch is also trivial. Please apply.
>    Found with help of smatch.
> 
> ===== drivers/net/sk98lin/skge.c 1.14 vs edited =====
> --- 1.14/drivers/net/sk98lin/skge.c	Wed Sep  3 21:15:10 2003
> +++ edited/drivers/net/sk98lin/skge.c	Sun Sep 21 15:38:01 2003
> @@ -3616,20 +3616,21 @@
>  			Length = sizeof(pAC->PnmiStruct) + HeaderLength;
>  		}
>  		if (NULL == (pMemBuf = kmalloc(Length, GFP_KERNEL))) {
> -			return -EFAULT;
> +			return -ENOMEM;
>  		}
>  		if(copy_from_user(pMemBuf, Ioctl.pData, Length)) {
> -			return -EFAULT;
> +			goto fault;
>  		}
>  		if ((Ret = SkPnmiGenIoctl(pAC, pAC->IoBase, pMemBuf, &Length, 0)) < 0) {
> -			return -EFAULT;
> +			goto fault;
>  		}
>  		if(copy_to_user(Ioctl.pData, pMemBuf, Length) ) {
> -			return -EFAULT;
> +			goto fault;
>  		}
>  		Ioctl.Len = Length;
>  		if(copy_to_user(rq->ifr_data, &Ioctl, sizeof(SK_GE_IOCTL))) {
> -			return -EFAULT;
> +fault:
> +			Err = -EFAULT;
>  		}
>  		kfree(pMemBuf); /* cleanup everything */
>  		break;
> 
> 
> <!DSPAM:3f6d8f69246641288117544>
> 



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-09-21 12:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-21 11:45 [PATCH] [2.4] Fix memleak on error exit path in sk98 driver Oleg Drokin
2003-09-21 14:14 ` Mirko Lindner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox