[2.4] Fix memleak on error exit path in sk98 driver.
PATCH 1/1 [2.4] Fix memleak on error exit path in sk98 driver.
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 =====
drivers/net/sk98lin/skge.c +6 -5
@@ -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 ;
Thank you. Will be done tomorrow.
Cheers,
Mirko
Quoted 40 lines · Oleg Drokin
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.c1.14 vs edited =====drivers/net/sk98lin/skge.c +6
-5@@ -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>