From patchwork Fri Jul 16 21:29:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarod Wilson X-Patchwork-Id: 3815 Return-path: Envelope-to: mchehab@infradead.org Delivery-date: Fri, 16 Jul 2010 21:29:59 +0000 Received: from bombadil.infradead.org [18.85.46.34] by localhost with IMAP (fetchmail-6.3.17) for (single-drop); Sat, 17 Jul 2010 03:41:13 -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 1OZsTn-0008Ur-I9; Fri, 16 Jul 2010 21:29:59 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966221Ab0GPV35 (ORCPT + 1 other); Fri, 16 Jul 2010 17:29:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1837 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966209Ab0GPV35 (ORCPT ); Fri, 16 Jul 2010 17:29:57 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6GLTvUo019849 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 16 Jul 2010 17:29:57 -0400 Received: from ihatethathostname.lab.bos.redhat.com (ihatethathostname.lab.bos.redhat.com [10.16.43.238]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6GLTtMA000785 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 16 Jul 2010 17:29:56 -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 o6GLTtni019989 for ; Fri, 16 Jul 2010 17:29:55 -0400 Received: (from jarod@localhost) by ihatethathostname.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o6GLTs9c019988 for linux-media@vger.kernel.org; Fri, 16 Jul 2010 17:29:54 -0400 X-Authentication-Warning: ihatethathostname.lab.bos.redhat.com: jarod set sender to jarod@redhat.com using -f Date: Fri, 16 Jul 2010 17:29:54 -0400 From: Jarod Wilson To: linux-media@vger.kernel.org Subject: [PATCH] IR/lirc: use memdup_user instead of copy_from_user Message-ID: <20100716212953.GA19872@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.17 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Inspired by 64047b94ede76e0c72ba8af98505e96d6a664519 Signed-off-by: Jarod Wilson --- drivers/media/IR/ir-lirc-codec.c | 11 +++-------- 1 files changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/media/IR/ir-lirc-codec.c b/drivers/media/IR/ir-lirc-codec.c index afb1ada..ee1f2d4 100644 --- a/drivers/media/IR/ir-lirc-codec.c +++ b/drivers/media/IR/ir-lirc-codec.c @@ -74,14 +74,9 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char *buf, if (count > LIRCBUF_SIZE || count % 2 == 0) return -EINVAL; - txbuf = kzalloc(sizeof(int) * LIRCBUF_SIZE, GFP_KERNEL); - if (!txbuf) - return -ENOMEM; - - if (copy_from_user(txbuf, buf, n)) { - ret = -EFAULT; - goto out; - } + txbuf = memdup_user(buf, n); + if (IS_ERR(txbuf)) + return PTR_ERR(txbuf); ir_dev = lirc->ir_dev; if (!ir_dev) {