diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2012-09-11 12:11:24 +0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-10-06 14:24:39 +0200 |
commit | 48cafec9a941c2dfe94d76642662bc20bf87fe08 (patch) | |
tree | 135943901bfccdb6a8e260fed60c6583fcc8021b /drivers/media/rc/ene_ir.c | |
parent | [media] ov2640: select sensor register bank before applying h/v-flip settings (diff) | |
download | linux-48cafec9a941c2dfe94d76642662bc20bf87fe08.tar.xz linux-48cafec9a941c2dfe94d76642662bc20bf87fe08.zip |
[media] rc: divide by zero bugs in s_tx_carrier()
"carrier" comes from a get_user() in ir_lirc_ioctl(). We need to test
that it's not zero before using it as a divisor. It might have been
nice to test for this ir_lirc_ioctl() but the mceusb driver uses zero to
disable carrier modulation.
The bug in redrat3 is a little more subtle. The ->carrier is passed to
mod_freq_to_val() which uses it as a divisor.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/rc/ene_ir.c')
-rw-r--r-- | drivers/media/rc/ene_ir.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/media/rc/ene_ir.c b/drivers/media/rc/ene_ir.c index 647dd951b0e8..d05ac15b5de4 100644 --- a/drivers/media/rc/ene_ir.c +++ b/drivers/media/rc/ene_ir.c @@ -881,10 +881,13 @@ static int ene_set_tx_mask(struct rc_dev *rdev, u32 tx_mask) static int ene_set_tx_carrier(struct rc_dev *rdev, u32 carrier) { struct ene_device *dev = rdev->priv; - u32 period = 2000000 / carrier; + u32 period; dbg("TX: attempt to set tx carrier to %d kHz", carrier); + if (carrier == 0) + return -EINVAL; + period = 2000000 / carrier; if (period && (period > ENE_CIRMOD_PRD_MAX || period < ENE_CIRMOD_PRD_MIN)) { |