diff options
Diffstat (limited to 'drivers/media/rc/ir-lirc-codec.c')
-rw-r--r-- | drivers/media/rc/ir-lirc-codec.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c index 1c5cc65ea1e1..e5eeec4da76e 100644 --- a/drivers/media/rc/ir-lirc-codec.c +++ b/drivers/media/rc/ir-lirc-codec.c | |||
@@ -103,19 +103,19 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char *buf, | |||
103 | { | 103 | { |
104 | struct lirc_codec *lirc; | 104 | struct lirc_codec *lirc; |
105 | struct rc_dev *dev; | 105 | struct rc_dev *dev; |
106 | int *txbuf; /* buffer with values to transmit */ | 106 | unsigned int *txbuf; /* buffer with values to transmit */ |
107 | int ret = 0; | 107 | ssize_t ret = 0; |
108 | size_t count; | 108 | size_t count; |
109 | 109 | ||
110 | lirc = lirc_get_pdata(file); | 110 | lirc = lirc_get_pdata(file); |
111 | if (!lirc) | 111 | if (!lirc) |
112 | return -EFAULT; | 112 | return -EFAULT; |
113 | 113 | ||
114 | if (n % sizeof(int)) | 114 | if (n < sizeof(unsigned) || n % sizeof(unsigned)) |
115 | return -EINVAL; | 115 | return -EINVAL; |
116 | 116 | ||
117 | count = n / sizeof(int); | 117 | count = n / sizeof(unsigned); |
118 | if (count > LIRCBUF_SIZE || count % 2 == 0 || n % sizeof(int) != 0) | 118 | if (count > LIRCBUF_SIZE || count % 2 == 0) |
119 | return -EINVAL; | 119 | return -EINVAL; |
120 | 120 | ||
121 | txbuf = memdup_user(buf, n); | 121 | txbuf = memdup_user(buf, n); |
@@ -129,7 +129,10 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char *buf, | |||
129 | } | 129 | } |
130 | 130 | ||
131 | if (dev->tx_ir) | 131 | if (dev->tx_ir) |
132 | ret = dev->tx_ir(dev, txbuf, (u32)n); | 132 | ret = dev->tx_ir(dev, txbuf, count); |
133 | |||
134 | if (ret > 0) | ||
135 | ret *= sizeof(unsigned); | ||
133 | 136 | ||
134 | out: | 137 | out: |
135 | kfree(txbuf); | 138 | kfree(txbuf); |