From patchwork Fri Sep 18 18:23:30 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pete Eberlein X-Patchwork-Id: 48660 X-Patchwork-Delegate: dougsland@redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8ILB9iD014153 for ; Fri, 18 Sep 2009 21:11:09 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756874AbZIRVKQ (ORCPT ); Fri, 18 Sep 2009 17:10:16 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757453AbZIRVKO (ORCPT ); Fri, 18 Sep 2009 17:10:14 -0400 Received: from gateway07.websitewelcome.com ([69.56.176.23]:49773 "HELO gateway07.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1755093AbZIRVKH (ORCPT ); Fri, 18 Sep 2009 17:10:07 -0400 Received: (qmail 27712 invoked from network); 18 Sep 2009 18:33:16 -0000 Received: from gator886.hostgator.com (174.120.40.226) by gateway07.websitewelcome.com with SMTP; 18 Sep 2009 18:33:16 -0000 Received: from [66.15.212.169] (port=30677 helo=[10.140.5.16]) by gator886.hostgator.com with esmtpsa (SSLv3:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1Moi7C-0002jL-6m for linux-media@vger.kernel.org; Fri, 18 Sep 2009 13:23:26 -0500 Subject: [PATCH 6/9] s2250-board: Fix memory leaks From: Pete To: "linux-media@vger.kernel.org" Date: Fri, 18 Sep 2009 11:23:30 -0700 Message-Id: <1253298210.4314.570.camel@pete-desktop> Mime-Version: 1.0 X-Mailer: Evolution 2.26.1 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator886.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - sensoray.com Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org In some error cases, allocated buffers need to be freed before returning. Priority: normal Signed-off-by: Pete Eberlein --- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff -r e227a099a9f2 -r bf8ee230f1a0 linux/drivers/staging/go7007/s2250-board.c --- a/linux/drivers/staging/go7007/s2250-board.c Fri Sep 18 10:37:01 2009 -0700 +++ b/linux/drivers/staging/go7007/s2250-board.c Fri Sep 18 10:39:03 2009 -0700 @@ -203,10 +203,13 @@ usb = go->hpi_context; if (mutex_lock_interruptible(&usb->i2c_lock) != 0) { printk(KERN_INFO "i2c lock failed\n"); + kfree(buf); return -EINTR; } - if (go7007_usb_vendor_request(go, 0x57, addr, val, buf, 16, 1) < 0) + if (go7007_usb_vendor_request(go, 0x57, addr, val, buf, 16, 1) < 0) { + kfree(buf); return -EFAULT; + } mutex_unlock(&usb->i2c_lock); if (buf[0] == 0) { @@ -214,6 +217,7 @@ subaddr = (buf[4] << 8) + buf[5]; val_read = (buf[2] << 8) + buf[3]; + kfree(buf); if (val_read != val) { printk(KERN_INFO "invalid fp write %x %x\n", val_read, val); @@ -224,8 +228,10 @@ subaddr, addr); return -EFAULT; } - } else + } else { + kfree(buf); return -EFAULT; + } /* save last 12b value */ if (addr == 0x12b)