History

[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.

Jarod Wilson committed 15 years ago

Commit 88914bd1 parent 559d1626 files · +20 −6Browse files

Showing the changes to drivers/staging/lirc/lirc_serial.c (1 of 6 files). Show all

Unified · Split

drivers/staging/lirc/lirc_serial.c+2−1
@@ -966,7 +966,7 @@ static ssize_t lirc_write(struct file *file, const char *buf, · 965 unmodified lines
966966 if (n % sizeof(int) || count % 2 == 0)
967967 return -EINVAL;
968968 wbuf = memdup_user(buf, n);
969− if (PTR_ERR(wbuf))
969+ if (IS_ERR(wbuf))
970970 return PTR_ERR(wbuf);
971971 spin_lock_irqsave(&hardware[type].lock, flags);
972972 if (type == LIRC_IRDEO) {
@@ -981,6 +981,7 @@ static ssize_t lirc_write(struct file *file, const char *buf, · 8 unmodified lines
981981 }
982982 off();
983983 spin_unlock_irqrestore(&hardware[type].lock, flags);
984+ kfree(wbuf);
984985 return n;
985986 }
986987