Commit b9d1081a authored by Mithlesh Thukral's avatar Mithlesh Thukral Committed by Greg Kroah-Hartman

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: default avatarLinSysSoft Sahara Team <saharaproj@linsyssoft.com>
Signed-off-by: default avatarMithlesh Thukral <mithlesh@linsyssoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 9914f053
...@@ -4212,6 +4212,21 @@ static int sxg_fill_descriptor_block(struct adapter_t *adapter, ...@@ -4212,6 +4212,21 @@ static int sxg_fill_descriptor_block(struct adapter_t *adapter,
adapter->FreeRcvBufferCount, adapter->AllRcvBlockCount); adapter->FreeRcvBufferCount, adapter->AllRcvBlockCount);
return (STATUS_SUCCESS); return (STATUS_SUCCESS);
no_memory: 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); return (-ENOMEM);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment