From: Alexander Beregalov <a.beregalov@gmail.com>
To: gregkh@suse.de
Cc: linux-kernel@vger.kernel.org,
Alexander Beregalov <a.beregalov@gmail.com>
Subject: [PATCH next 2/6] staging: bcm: fix memory leaks
Date: Thu, 10 Mar 2011 05:43:04 +0300 [thread overview]
Message-ID: <1299724988-25351-2-git-send-email-a.beregalov@gmail.com> (raw)
In-Reply-To: <1299724988-25351-1-git-send-email-a.beregalov@gmail.com>
Free resources before exit.
Signed-off-by: Alexander Beregalov <a.beregalov@gmail.com>
---
drivers/staging/bcm/Bcmchar.c | 1 +
drivers/staging/bcm/CmHost.c | 46 ++++++++++++++++++++++++++++------------
2 files changed, 33 insertions(+), 14 deletions(-)
diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c
index 867dbf1..0013315 100644
--- a/drivers/staging/bcm/Bcmchar.c
+++ b/drivers/staging/bcm/Bcmchar.c
@@ -311,6 +311,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
{
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "RDM Done On invalid Address : %x Access Denied.\n",
(int)sRdmBuffer.Register);
+ kfree(temp_buff);
return -EINVAL;
}
diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c
index 017b471..6b9d8b1 100644
--- a/drivers/staging/bcm/CmHost.c
+++ b/drivers/staging/bcm/CmHost.c
@@ -1671,6 +1671,7 @@ ULONG StoreCmControlResponseMessage(PMINI_ADAPTER Adapter,PVOID pvBuffer,UINT *p
stLocalSFDeleteRequest *pstDeletionRequest;
UINT uiSearchRuleIndex;
ULONG ulSFID;
+ ULONG ret;
pstAddIndicationAlt = (stLocalSFAddIndicationAlt *)(pvBuffer);
@@ -1709,12 +1710,16 @@ ULONG StoreCmControlResponseMessage(PMINI_ADAPTER Adapter,PVOID pvBuffer,UINT *p
/* AUTHORIZED SET */
pstAddIndication->psfAuthorizedSet = (stServiceFlowParamSI *)
GetNextTargetBufferLocation(Adapter, pstAddIndicationAlt->u16TID);
- if(!pstAddIndication->psfAuthorizedSet)
- return 0;
+ if(!pstAddIndication->psfAuthorizedSet) {
+ ret = 0
+ goto exit;
+ }
if(StoreSFParam(Adapter,(PUCHAR)&pstAddIndicationAlt->sfAuthorizedSet,
- (ULONG)pstAddIndication->psfAuthorizedSet)!= 1)
- return 0;
+ (ULONG)pstAddIndication->psfAuthorizedSet)!= 1) {
+ ret = 0;
+ goto exit;
+ }
/* this can't possibly be right */
pstAddIndication->psfAuthorizedSet = (stServiceFlowParamSI *)ntohl((ULONG)pstAddIndication->psfAuthorizedSet);
@@ -1731,7 +1736,8 @@ ULONG StoreCmControlResponseMessage(PMINI_ADAPTER Adapter,PVOID pvBuffer,UINT *p
AddRequest.psfParameterSet =pstAddIndication->psfAuthorizedSet ;
(*puBufferLength) = sizeof(stLocalSFAddRequest);
memcpy(pvBuffer,&AddRequest,sizeof(stLocalSFAddRequest));
- return 1;
+ ret = 1;
+ goto exit;
}
// Since it's not DSA_REQ, we can access all field in pstAddIndicationAlt
@@ -1748,10 +1754,14 @@ ULONG StoreCmControlResponseMessage(PMINI_ADAPTER Adapter,PVOID pvBuffer,UINT *p
/* ADMITTED SET */
pstAddIndication->psfAdmittedSet = (stServiceFlowParamSI *)
GetNextTargetBufferLocation(Adapter, pstAddIndicationAlt->u16TID);
- if(!pstAddIndication->psfAdmittedSet)
- return 0;
- if(StoreSFParam(Adapter,(PUCHAR)&pstAddIndicationAlt->sfAdmittedSet,(ULONG)pstAddIndication->psfAdmittedSet) != 1)
- return 0;
+ if(!pstAddIndication->psfAdmittedSet) {
+ ret = 0;
+ goto exit;
+ }
+ if(StoreSFParam(Adapter,(PUCHAR)&pstAddIndicationAlt->sfAdmittedSet,(ULONG)pstAddIndication->psfAdmittedSet) != 1) {
+ ret = 0;
+ goto exit;
+ }
pstAddIndication->psfAdmittedSet = (stServiceFlowParamSI *)ntohl((ULONG)pstAddIndication->psfAdmittedSet);
@@ -1759,17 +1769,25 @@ ULONG StoreCmControlResponseMessage(PMINI_ADAPTER Adapter,PVOID pvBuffer,UINT *p
/* ACTIVE SET */
pstAddIndication->psfActiveSet = (stServiceFlowParamSI *)
GetNextTargetBufferLocation(Adapter, pstAddIndicationAlt->u16TID);
- if(!pstAddIndication->psfActiveSet)
- return 0;
- if(StoreSFParam(Adapter,(PUCHAR)&pstAddIndicationAlt->sfActiveSet,(ULONG)pstAddIndication->psfActiveSet) != 1)
- return 0;
+ if(!pstAddIndication->psfActiveSet) {
+ ret = 0;
+ goto exit;
+ }
+ if(StoreSFParam(Adapter,(PUCHAR)&pstAddIndicationAlt->sfActiveSet,(ULONG)pstAddIndication->psfActiveSet) != 1) {
+ ret = 0;
+ goto exit;
+ }
pstAddIndication->psfActiveSet = (stServiceFlowParamSI *)ntohl((ULONG)pstAddIndication->psfActiveSet);
(*puBufferLength) = sizeof(stLocalSFAddIndication);
*(stLocalSFAddIndication *)pvBuffer = *pstAddIndication;
+
+ ret = 1;
+
+exit:
kfree(pstAddIndication);
- return 1;
+ return ret;
}
--
1.7.4.1
next prev parent reply other threads:[~2011-03-10 2:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-10 2:43 [PATCH next 1/6] staging: altera-stapl: " Alexander Beregalov
2011-03-10 2:43 ` Alexander Beregalov [this message]
2011-03-11 22:31 ` [PATCH next 2/6] staging: bcm: " Greg KH
2011-03-13 19:00 ` Alexander Beregalov
2011-03-10 2:43 ` [PATCH next 3/6] staging: brcm80211: " Alexander Beregalov
2011-03-10 2:43 ` [PATCH next 4/6] staging: crystalhd: " Alexander Beregalov
2011-03-10 2:43 ` [PATCH next 5/6] staging: hv: " Alexander Beregalov
2011-03-10 2:43 ` [PATCH next 6/6] staging: ste_rmi4: " Alexander Beregalov
2011-03-11 22:29 ` [PATCH next 1/6] staging: altera-stapl: " Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1299724988-25351-2-git-send-email-a.beregalov@gmail.com \
--to=a.beregalov@gmail.com \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®