From patchwork Thu Apr 7 19:34:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesper Juhl X-Patchwork-Id: 693361 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p388EDrP003611 for ; Fri, 8 Apr 2011 08:14:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756703Ab1DGTeN (ORCPT ); Thu, 7 Apr 2011 15:34:13 -0400 Received: from swampdragon.chaosbits.net ([90.184.90.115]:13345 "EHLO swampdragon.chaosbits.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756591Ab1DGTeN (ORCPT ); Thu, 7 Apr 2011 15:34:13 -0400 Received: by swampdragon.chaosbits.net (Postfix, from userid 1000) id A31E39403E; Thu, 7 Apr 2011 21:34:30 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by swampdragon.chaosbits.net (Postfix) with ESMTP id 90B4B9403B; Thu, 7 Apr 2011 21:34:30 +0200 (CEST) Date: Thu, 7 Apr 2011 21:34:30 +0200 (CEST) From: Jesper Juhl To: Mauro Carvalho Chehab cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Dan Carpenter , Olivier Grenie , Patrick Boettcher Subject: [PATCH][media] DVB, DiB9000: Fix leak in dib9000_attach() Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 08 Apr 2011 08:14:21 +0000 (UTC) If the second memory allocation in dib9000_attach() fails, we'll leak the memory allocated by the first. Signed-off-by: Jesper Juhl --- dib9000.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) compile tested only... diff --git a/drivers/media/dvb/frontends/dib9000.c b/drivers/media/dvb/frontends/dib9000.c index 9151876..b25ef2b 100644 --- a/drivers/media/dvb/frontends/dib9000.c +++ b/drivers/media/dvb/frontends/dib9000.c @@ -2255,8 +2255,10 @@ struct dvb_frontend *dib9000_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, c if (st == NULL) return NULL; fe = kzalloc(sizeof(struct dvb_frontend), GFP_KERNEL); - if (fe == NULL) + if (fe == NULL) { + kfree(st); return NULL; + } memcpy(&st->chip.d9.cfg, cfg, sizeof(struct dib9000_config)); st->i2c.i2c_adap = i2c_adap;