aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarod Wilson <jarod@redhat.com>2011-01-17 14:02:00 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-01-19 09:52:22 -0500
commit88914bdf8c677ebd7e797adac05e47303fd6ac77 (patch)
tree6ba8b683d9b19ee4d2d7aa0836b1f2cf7dc4d1f6
parent559d162e1ebcdb61e89f154f2c2db376af072b0e (diff)
[media] staging/lirc: fix mem leaks and ptr err usage
When the lirc drivers were converted over to using memdup_user, I mistakenly also removed corresponding calls to kfree. Add those back. I also screwed up on the allocation error check in lirc_serial, using if (PTR_ERR()) instead of if (IS_ERR()), which broke transmit. Reported-by: Jiri Fojtasek <jiri.fojtasek@hlohovec.net> Signed-off-by: Jarod Wilson <jarod@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/staging/lirc/lirc_imon.c1
-rw-r--r--drivers/staging/lirc/lirc_it87.c1
-rw-r--r--drivers/staging/lirc/lirc_parallel.c19
-rw-r--r--drivers/staging/lirc/lirc_sasem.c1
-rw-r--r--drivers/staging/lirc/lirc_serial.c3
-rw-r--r--drivers/staging/lirc/lirc_sir.c1
6 files changed, 20 insertions, 6 deletions
diff --git a/drivers/staging/lirc/lirc_imon.c b/drivers/staging/lirc/lirc_imon.c
index 0da6b9518af9..235cab0eb087 100644
--- a/drivers/staging/lirc/lirc_imon.c
+++ b/drivers/staging/lirc/lirc_imon.c
@@ -447,6 +447,7 @@ static ssize_t vfd_write(struct file *file, const char *buf,
447 447
448exit: 448exit:
449 mutex_unlock(&context->ctx_lock); 449 mutex_unlock(&context->ctx_lock);
450 kfree(data_buf);
450 451
451 return (!retval) ? n_bytes : retval; 452 return (!retval) ? n_bytes : retval;
452} 453}
diff --git a/drivers/staging/lirc/lirc_it87.c b/drivers/staging/lirc/lirc_it87.c
index 929ae5795467..5938616f3e8f 100644
--- a/drivers/staging/lirc/lirc_it87.c
+++ b/drivers/staging/lirc/lirc_it87.c
@@ -232,6 +232,7 @@ static ssize_t lirc_write(struct file *file, const char *buf,
232 i++; 232 i++;
233 } 233 }
234 terminate_send(tx_buf[i - 1]); 234 terminate_send(tx_buf[i - 1]);
235 kfree(tx_buf);
235 return n; 236 return n;
236} 237}
237 238
diff --git a/drivers/staging/lirc/lirc_parallel.c b/drivers/staging/lirc/lirc_parallel.c
index dfd2c447e67d..3a9c09881b2b 100644
--- a/drivers/staging/lirc/lirc_parallel.c
+++ b/drivers/staging/lirc/lirc_parallel.c
@@ -376,6 +376,7 @@ static ssize_t lirc_write(struct file *filep, const char *buf, size_t n,
376 unsigned long flags; 376 unsigned long flags;
377 int counttimer; 377 int counttimer;
378 int *wbuf; 378 int *wbuf;
379 ssize_t ret;
379 380
380 if (!is_claimed) 381 if (!is_claimed)
381 return -EBUSY; 382 return -EBUSY;
@@ -393,8 +394,10 @@ static ssize_t lirc_write(struct file *filep, const char *buf, size_t n,
393 if (timer == 0) { 394 if (timer == 0) {
394 /* try again if device is ready */ 395 /* try again if device is ready */
395 timer = init_lirc_timer(); 396 timer = init_lirc_timer();
396 if (timer == 0) 397 if (timer == 0) {
397 return -EIO; 398 ret = -EIO;
399 goto out;
400 }
398 } 401 }
399 402
400 /* adjust values from usecs */ 403 /* adjust values from usecs */
@@ -420,7 +423,8 @@ static ssize_t lirc_write(struct file *filep, const char *buf, size_t n,
420 if (check_pselecd && (in(1) & LP_PSELECD)) { 423 if (check_pselecd && (in(1) & LP_PSELECD)) {
421 lirc_off(); 424 lirc_off();
422 local_irq_restore(flags); 425 local_irq_restore(flags);
423 return -EIO; 426 ret = -EIO;
427 goto out;
424 } 428 }
425 } while (counttimer < wbuf[i]); 429 } while (counttimer < wbuf[i]);
426 i++; 430 i++;
@@ -436,7 +440,8 @@ static ssize_t lirc_write(struct file *filep, const char *buf, size_t n,
436 level = newlevel; 440 level = newlevel;
437 if (check_pselecd && (in(1) & LP_PSELECD)) { 441 if (check_pselecd && (in(1) & LP_PSELECD)) {
438 local_irq_restore(flags); 442 local_irq_restore(flags);
439 return -EIO; 443 ret = -EIO;
444 goto out;
440 } 445 }
441 } while (counttimer < wbuf[i]); 446 } while (counttimer < wbuf[i]);
442 i++; 447 i++;
@@ -445,7 +450,11 @@ static ssize_t lirc_write(struct file *filep, const char *buf, size_t n,
445#else 450#else
446 /* place code that handles write without external timer here */ 451 /* place code that handles write without external timer here */
447#endif 452#endif
448 return n; 453 ret = n;
454out:
455 kfree(wbuf);
456
457 return ret;
449} 458}
450 459
451static unsigned int lirc_poll(struct file *file, poll_table *wait) 460static unsigned int lirc_poll(struct file *file, poll_table *wait)
diff --git a/drivers/staging/lirc/lirc_sasem.c b/drivers/staging/lirc/lirc_sasem.c
index 998485ebdbce..925eabe14854 100644
--- a/drivers/staging/lirc/lirc_sasem.c
+++ b/drivers/staging/lirc/lirc_sasem.c
@@ -448,6 +448,7 @@ static ssize_t vfd_write(struct file *file, const char *buf,
448exit: 448exit:
449 449
450 mutex_unlock(&context->ctx_lock); 450 mutex_unlock(&context->ctx_lock);
451 kfree(data_buf);
451 452
452 return (!retval) ? n_bytes : retval; 453 return (!retval) ? n_bytes : retval;
453} 454}
diff --git a/drivers/staging/lirc/lirc_serial.c b/drivers/staging/lirc/lirc_serial.c
index 9bcf149c4260..1c3099b388e0 100644
--- a/drivers/staging/lirc/lirc_serial.c
+++ b/drivers/staging/lirc/lirc_serial.c
@@ -966,7 +966,7 @@ static ssize_t lirc_write(struct file *file, const char *buf,
966 if (n % sizeof(int) || count % 2 == 0) 966 if (n % sizeof(int) || count % 2 == 0)
967 return -EINVAL; 967 return -EINVAL;
968 wbuf = memdup_user(buf, n); 968 wbuf = memdup_user(buf, n);
969 if (PTR_ERR(wbuf)) 969 if (IS_ERR(wbuf))
970 return PTR_ERR(wbuf); 970 return PTR_ERR(wbuf);
971 spin_lock_irqsave(&hardware[type].lock, flags); 971 spin_lock_irqsave(&hardware[type].lock, flags);
972 if (type == LIRC_IRDEO) { 972 if (type == LIRC_IRDEO) {
@@ -981,6 +981,7 @@ static ssize_t lirc_write(struct file *file, const char *buf,
981 } 981 }
982 off(); 982 off();
983 spin_unlock_irqrestore(&hardware[type].lock, flags); 983 spin_unlock_irqrestore(&hardware[type].lock, flags);
984 kfree(wbuf);
984 return n; 985 return n;
985} 986}
986 987
diff --git a/drivers/staging/lirc/lirc_sir.c b/drivers/staging/lirc/lirc_sir.c
index c553ab626238..76be7b8c6209 100644
--- a/drivers/staging/lirc/lirc_sir.c
+++ b/drivers/staging/lirc/lirc_sir.c
@@ -330,6 +330,7 @@ static ssize_t lirc_write(struct file *file, const char *buf, size_t n,
330 /* enable receiver */ 330 /* enable receiver */
331 Ser2UTCR3 = UTCR3_RXE|UTCR3_RIE; 331 Ser2UTCR3 = UTCR3_RXE|UTCR3_RIE;
332#endif 332#endif
333 kfree(tx_buf);
333 return count; 334 return count;
334} 335}
335 336