diff options
author | Mithlesh Thukral <mithlesh@linsyssoft.com> | 2009-02-18 18:52:18 +0530 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-04-03 14:53:12 -0700 |
commit | b9d1081a833806e2f8ee7d8b827202e1bd5949b2 (patch) | |
tree | 39830ec9ca92e03b721442d196cfdd450e3f3127 | |
parent | 9914f0536f0e87c13ad51971f0ddcda007436f34 (diff) | |
download | op-kernel-dev-b9d1081a833806e2f8ee7d8b827202e1bd5949b2.zip op-kernel-dev-b9d1081a833806e2f8ee7d8b827202e1bd5949b2.tar.gz |
Staging: sxg: Fix memory leak in case of allocation failure
* Fix a memory leak if allocation of skb fails in sxg_fill_descriptor_block.
In sxg_fill_descriptor_block(), if allocation of skb failed in loop,
we just came out shouting. This rollbacks all the successful operation
before skb allocation fails and then returns.
Signed-off-by: LinSysSoft Sahara Team <saharaproj@linsyssoft.com>
Signed-off-by: Mithlesh Thukral <mithlesh@linsyssoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/staging/sxg/sxg.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/staging/sxg/sxg.c b/drivers/staging/sxg/sxg.c index da286f5..9ce3af5 100644 --- a/drivers/staging/sxg/sxg.c +++ b/drivers/staging/sxg/sxg.c @@ -4212,6 +4212,21 @@ static int sxg_fill_descriptor_block(struct adapter_t *adapter, adapter->FreeRcvBufferCount, adapter->AllRcvBlockCount); return (STATUS_SUCCESS); no_memory: + for (; i >= 0 ; i--) { + if (RcvDescriptorBlock->Descriptors[i].VirtualAddress) { + RcvDataBufferHdr = (struct sxg_rcv_data_buffer_hdr *) + RcvDescriptorBlock->Descriptors[i]. + VirtualAddress; + RcvDescriptorBlock->Descriptors[i].PhysicalAddress = + (dma_addr_t)NULL; + RcvDescriptorBlock->Descriptors[i].VirtualAddress=NULL; + } + SXG_FREE_RCV_DATA_BUFFER(adapter, RcvDataBufferHdr); + } + RcvDescriptorBlockHdr->State = SXG_BUFFER_FREE; + SXG_RETURN_CMD(RingZero, RcvRingInfo, RingDescriptorCmd, + RcvDescriptorBlockHdr); + return (-ENOMEM); } |