linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Young <sean@mess.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: "Mauro Carvalho Chehab" <mchehab@infradead.org>,
	"Paul Gortmaker" <paul.gortmaker@windriver.com>,
	"David Härdeman" <david@hardeman.nu>,
	"Ben Hutchings" <ben@decadent.org.uk>,
	linux-media@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch v2] [media] rc-core: prevent divide by zero bug in s_tx_carrier()
Date: Sun, 9 Sep 2012 23:26:30 +0100	[thread overview]
Message-ID: <20120909222629.GA28355@pequod.mess.org> (raw)
In-Reply-To: <20120909203142.GA12296@elgon.mountain>

On Sun, Sep 09, 2012 at 11:31:42PM +0300, Dan Carpenter wrote:
> 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 <dan.carpenter@oracle.com>
> ---
> v2: Ben Hutchings pointed out that my first patch was not a complete
>     fix.
> 
> 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;

This should be ENOSYS.

>  
> +		if (val <= 0)
> +			return -EINVAL;
> +

1) val is unsigned so it would never be less than zero.

2) A value of zero means disabling carrier modulation, which is used by 
   the mceusb driver.

So the check belongs in the individual drivers, as in the original patch.


Sean

  parent reply	other threads:[~2012-09-09 22:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-09 20:31 [patch v2] [media] rc-core: prevent divide by zero bug in s_tx_carrier() Dan Carpenter
2012-09-09 21:01 ` walter harms
2012-09-09 22:00   ` Ben Hutchings
2012-09-09 22:26 ` Sean Young [this message]
2012-09-09 22:38   ` Ben Hutchings
2012-09-11 11:11   ` [patch v3] [media] rc: divide by zero bugs " Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120909222629.GA28355@pequod.mess.org \
    --to=sean@mess.org \
    --cc=ben@decadent.org.uk \
    --cc=dan.carpenter@oracle.com \
    --cc=david@hardeman.nu \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@infradead.org \
    --cc=paul.gortmaker@windriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).