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
157 157
158static int lirc_cdev_add(struct irctl *ir)158static int lirc_cdev_add(struct irctl *ir)
159{159{
160 int retval = -ENOMEM;
161 struct lirc_driver *d = &ir->d;160 struct lirc_driver *d = &ir->d;
162 struct cdev *cdev;161 struct cdev *cdev;
162 int retval;
163 163
164 cdev = cdev_alloc();164 cdev = cdev_alloc();
165 if (!cdev)165 if (!cdev)
166 goto err_out;166 return -ENOMEM;
167 167
168 if (d->fops) {168 if (d->fops) {
169 cdev->ops = d->fops;169 cdev->ops = d->fops;
@@ -177,10 +177,8 @@ static int lirc_cdev_add(struct irctl *ir) · 7 unmodified lines
177 goto err_out;177 goto err_out;
178 178
179 retval = cdev_add(cdev, MKDEV(MAJOR(lirc_base_dev), d->minor), 1);179 retval = cdev_add(cdev, MKDEV(MAJOR(lirc_base_dev), d->minor), 1);
180 if (retval) {180 if (retval)
181 kobject_put(&cdev->kobj);
182 goto err_out;181 goto err_out;
183 }
184 182
185 ir->cdev = cdev;183 ir->cdev = cdev;
186 184

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