linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: walter harms <wharms@bfs.de>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: "Mauro Carvalho Chehab" <mchehab@infradead.org>,
	"Paul Gortmaker" <paul.gortmaker@windriver.com>,
	"Sean Young" <sean@mess.org>,
	"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, 09 Sep 2012 23:01:49 +0200	[thread overview]
Message-ID: <504D03BD.8010203@bfs.de> (raw)
In-Reply-To: <20120909203142.GA12296@elgon.mountain>

Hi all,
I am not sure if that is a good idea.
it should be in the hands of the driver who to use these 'val'
some driver may need a higher value like this one:

static int iguanair_set_tx_carrier(struct rc_dev *dev, uint32_t carrier)
{
	struct iguanair *ir = dev->priv;

	if (carrier < 25000 || carrier > 150000)
		return -EINVAL;

There are also examples where 0 has a special meaning (to be fair not
with this function). Example:
  cfsetospeed() ...  The zero baud rate, B0, is used to terminate the connection.

I have no clue who will use the 0 but ...

just my 2 cents,
re,
 wh

Am 09.09.2012 22:31, schrieb Dan Carpenter:
> 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;
>  
> +		if (val <= 0)
> +			return -EINVAL;
> +
>  		return dev->s_tx_carrier(dev, val);
>  
>  	case LIRC_SET_SEND_DUTY_CYCLE:





  reply	other threads:[~2012-09-09 21:01 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 [this message]
2012-09-09 22:00   ` Ben Hutchings
2012-09-09 22:26 ` Sean Young
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=504D03BD.8010203@bfs.de \
    --to=wharms@bfs.de \
    --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 \
    --cc=sean@mess.org \
    /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).