Skip to content

Commit

Permalink
drivers/char/pcmcia/ipwireless/hardware.c fix resource leak
Browse files Browse the repository at this point in the history
Coverity CID: 2172 RESOURCE_LEAK

When pool_allocate() tries to enlarge a packet, if it can not allocate enough
memory, it returns NULL without first freeing the old packet.

This patch just frees the packet first.

Signed-off-by: Darren Jenkins <[email protected]>
Acked-by: Jiri Kosina <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
DarrenRJ authored and torvalds committed Jul 12, 2008
1 parent a26929f commit 43f77e9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/char/pcmcia/ipwireless/hardware.c
Original file line number Diff line number Diff line change
Expand Up @@ -590,8 +590,10 @@ static struct ipw_rx_packet *pool_allocate(struct ipw_hardware *hw,
packet = kmalloc(sizeof(struct ipw_rx_packet) +
old_packet->length + minimum_free_space,
GFP_ATOMIC);
if (!packet)
if (!packet) {
kfree(old_packet);
return NULL;
}
memcpy(packet, old_packet,
sizeof(struct ipw_rx_packet)
+ old_packet->length);
Expand Down

0 comments on commit 43f77e9

Please sign in to comment.