History

[media] lirc: fix error paths in lirc_cdev_add()

"c77d17c0 [media] lirc: use-after free" introduces two problems: cdev_del() can be called with a NULL argument, and the kobject_put() path will cause a double free.

Sean Young committed 9 years ago

Commit b40769e1 parent 00361131 file · +3 −5Browse files

Unified · Split

drivers/media/rc/lirc_dev.c+3−5
@@ -157,13 +157,13 @@ static const struct file_operations lirc_dev_fops = { · 156 unmodified lines
157157
158158 static int lirc_cdev_add(struct irctl *ir)
159159 {
160− int retval = -ENOMEM;
161160 struct lirc_driver *d = &ir->d;
162161 struct cdev *cdev;
162+ int retval;
163163
164164 cdev = cdev_alloc();
165165 if (!cdev)
166− goto err_out;
166+ return -ENOMEM;
167167
168168 if (d->fops) {
169169 cdev->ops = d->fops;
@@ -177,10 +177,8 @@ static int lirc_cdev_add(struct irctl *ir) · 7 unmodified lines
177177 goto err_out;
178178
179179 retval = cdev_add(cdev, MKDEV(MAJOR(lirc_base_dev), d->minor), 1);
180− if (retval) {
181− kobject_put(&cdev->kobj);
180+ if (retval)
182181 goto err_out;
183− }
184182
185183 ir->cdev = cdev;
186184

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t