From patchwork Wed Jul 28 02:24:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarod Wilson X-Patchwork-Id: 3919 Return-path: Envelope-to: mchehab@infradead.org Delivery-date: Wed, 28 Jul 2010 02:24:08 +0000 Received: from bombadil.infradead.org [18.85.46.34] by pedra with IMAP (fetchmail-6.3.17) for (single-drop); Tue, 27 Jul 2010 23:28:02 -0300 (BRT) Received: from vger.kernel.org ([209.132.180.67]) by bombadil.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1OdwJU-0003GD-9t; Wed, 28 Jul 2010 02:24:08 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752101Ab0G1CYG (ORCPT + 1 other); Tue, 27 Jul 2010 22:24:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8832 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751439Ab0G1CYD (ORCPT ); Tue, 27 Jul 2010 22:24:03 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6S2O1kK000877 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 27 Jul 2010 22:24:02 -0400 Received: from ihatethathostname.lab.bos.redhat.com (ihatethathostname.lab.bos.redhat.com [10.16.43.238]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6S2O1cI023720 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 27 Jul 2010 22:24:01 -0400 Received: from ihatethathostname.lab.bos.redhat.com (ihatethathostname.lab.bos.redhat.com [127.0.0.1]) by ihatethathostname.lab.bos.redhat.com (8.14.4/8.14.3) with ESMTP id o6S2O0uh005419; Tue, 27 Jul 2010 22:24:00 -0400 Received: (from jarod@localhost) by ihatethathostname.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o6S2O0rC005417; Tue, 27 Jul 2010 22:24:00 -0400 X-Authentication-Warning: ihatethathostname.lab.bos.redhat.com: jarod set sender to jarod@redhat.com using -f Date: Tue, 27 Jul 2010 22:24:00 -0400 From: Jarod Wilson To: linux-media@vger.kernel.org Cc: Maxim Levitsky Subject: [PATCH] IR/mceusb: remove bad ir_input_dev use Message-ID: <20100728022400.GA5398@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The ir_input_dev gets filled in by __ir_input_register, the one allocated in mceusb_init_input_dev was being overwritten by the correct one shortly after it was initialized (ultimately resulting in a memory leak). This bug was inherited from imon.c, and was pointed out to me by Maxim Levitsky. CC: Maxim Levitsky Signed-off-by: Jarod Wilson --- drivers/media/IR/mceusb.c | 15 +-------------- 1 files changed, 1 insertions(+), 14 deletions(-) diff --git a/drivers/media/IR/mceusb.c b/drivers/media/IR/mceusb.c index 78bf7f7..9a7da32 100644 --- a/drivers/media/IR/mceusb.c +++ b/drivers/media/IR/mceusb.c @@ -228,7 +228,6 @@ static struct usb_device_id std_tx_mask_list[] = { /* data structure for each usb transceiver */ struct mceusb_dev { /* ir-core bits */ - struct ir_input_dev *irdev; struct ir_dev_props *props; struct ir_raw_event rawir; @@ -739,7 +738,7 @@ static void mceusb_dev_recv(struct urb *urb, struct pt_regs *regs) if (ir->send_flags == RECV_FLAG_IN_PROGRESS) { ir->send_flags = SEND_FLAG_COMPLETE; - dev_dbg(&ir->irdev->dev, "setup answer received %d bytes\n", + dev_dbg(&ir->dev, "setup answer received %d bytes\n", buf_len); } @@ -861,7 +860,6 @@ static struct input_dev *mceusb_init_input_dev(struct mceusb_dev *ir) { struct input_dev *idev; struct ir_dev_props *props; - struct ir_input_dev *irdev; struct device *dev = ir->dev; int ret = -ENODEV; @@ -878,12 +876,6 @@ static struct input_dev *mceusb_init_input_dev(struct mceusb_dev *ir) goto props_alloc_failed; } - irdev = kzalloc(sizeof(struct ir_input_dev), GFP_KERNEL); - if (!irdev) { - dev_err(dev, "remote ir input dev allocation failed\n"); - goto ir_dev_alloc_failed; - } - snprintf(ir->name, sizeof(ir->name), "Media Center Ed. eHome " "Infrared Remote Transceiver (%04x:%04x)", le16_to_cpu(ir->usbdev->descriptor.idVendor), @@ -902,9 +894,6 @@ static struct input_dev *mceusb_init_input_dev(struct mceusb_dev *ir) props->tx_ir = mceusb_tx_ir; ir->props = props; - ir->irdev = irdev; - - input_set_drvdata(idev, irdev); ret = ir_input_register(idev, RC_MAP_RC6_MCE, props, DRIVER_NAME); if (ret < 0) { @@ -915,8 +904,6 @@ static struct input_dev *mceusb_init_input_dev(struct mceusb_dev *ir) return idev; irdev_failed: - kfree(irdev); -ir_dev_alloc_failed: kfree(props); props_alloc_failed: input_free_device(idev);