From patchwork Sun Sep 9 20:31:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 1428041 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 52DCC4025E for ; Sun, 9 Sep 2012 20:32:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754784Ab2IIUch (ORCPT ); Sun, 9 Sep 2012 16:32:37 -0400 Received: from rcsinet15.oracle.com ([148.87.113.117]:47570 "EHLO rcsinet15.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754596Ab2IIUcg (ORCPT ); Sun, 9 Sep 2012 16:32:36 -0400 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by rcsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q89KVlCp021449 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 9 Sep 2012 20:31:48 GMT Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q89KVjYJ002724 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 9 Sep 2012 20:31:46 GMT Received: from abhmt105.oracle.com (abhmt105.oracle.com [141.146.116.57]) by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q89KVhAu030105; Sun, 9 Sep 2012 15:31:43 -0500 Received: from elgon.mountain (/41.212.103.53) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 09 Sep 2012 13:31:43 -0700 Date: Sun, 9 Sep 2012 23:31:42 +0300 From: Dan Carpenter To: Mauro Carvalho Chehab Cc: Paul Gortmaker , Sean Young , David =?iso-8859-1?Q?H=E4rdeman?= , Ben Hutchings , linux-media@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch v2] [media] rc-core: prevent divide by zero bug in s_tx_carrier() Message-ID: <20120909203142.GA12296@elgon.mountain> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: ucsinet21.oracle.com [156.151.31.93] Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Several of the drivers use carrier as a divisor in their s_tx_carrier() functions. We should do a sanity check here like we do for LIRC_SET_REC_CARRIER. Signed-off-by: Dan Carpenter --- v2: Ben Hutchings pointed out that my first patch was not a complete fix. -- 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 --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c index 6ad4a07..28dc0f0 100644 --- a/drivers/media/rc/ir-lirc-codec.c +++ b/drivers/media/rc/ir-lirc-codec.c @@ -211,6 +211,9 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, if (!dev->s_tx_carrier) return -EINVAL; + if (val <= 0) + return -EINVAL; + return dev->s_tx_carrier(dev, val); case LIRC_SET_SEND_DUTY_CYCLE: