Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754553AbYGGKFm (ORCPT ); Mon, 7 Jul 2008 06:05:42 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752535AbYGGKFe (ORCPT ); Mon, 7 Jul 2008 06:05:34 -0400 Received: from py-out-1112.google.com ([64.233.166.182]:59882 "EHLO py-out-1112.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752326AbYGGKFd (ORCPT ); Mon, 7 Jul 2008 06:05:33 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:content-type:date:message-id:mime-version:x-mailer :content-transfer-encoding; b=wqCcuwOH+ayT62l4CExQ48F/mvVxAEUhdMP1hup5PZuCpWAsqKr7oO68GFCggO3VpV 1eUUBVvzz6KEKEfl8n4CRJEtsxFumhNlqNrWmTzBvcPAdr7eGBuGPMN+a/dzPvBA0jf4 yuvsdUQaNOMKtzFKT92qHfMjME1MdoDly7qI4= Subject: [PATCH] drivers/char/pcmcia/ipwireless/hardware.c fix resource leak From: "Darren Jenkins\\" To: kernel Janitors , LKML , jkosina@suse.cz, dsterba@suse.cz Content-Type: text/plain; charset=UTF-8 Date: Mon, 07 Jul 2008 08:18:10 +1000 Message-Id: <1215382690.11092.11.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.22.2 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1146 Lines: 34 G'day people, 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 diff --git a/drivers/char/pcmcia/ipwireless/hardware.c b/drivers/char/pcmcia/ipwireless/hardware.c index ba6340a..929101e 100644 --- a/drivers/char/pcmcia/ipwireless/hardware.c +++ b/drivers/char/pcmcia/ipwireless/hardware.c @@ -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); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/