Skip to content

Commit

Permalink
media: rc: do not access device via sysfs after rc_unregister_device()
Browse files Browse the repository at this point in the history
Device drivers do not expect to have change_protocol or wakeup
re-programming to be accesed after rc_unregister_device(). This can
cause the device driver to access deallocated resources.

Cc: <stable@vger.kernel.org> # 4.16+
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
  • Loading branch information
seanyoung authored and mchehab committed Aug 28, 2020
1 parent 4f0835d commit a2e2d73
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions drivers/media/rc/rc-main.c
Expand Up @@ -1292,6 +1292,10 @@ static ssize_t store_protocols(struct device *device,
}

mutex_lock(&dev->lock);
if (!dev->registered) {
mutex_unlock(&dev->lock);
return -ENODEV;
}

old_protocols = *current_protocols;
new_protocols = old_protocols;
Expand Down Expand Up @@ -1430,6 +1434,10 @@ static ssize_t store_filter(struct device *device,
return -EINVAL;

mutex_lock(&dev->lock);
if (!dev->registered) {
mutex_unlock(&dev->lock);
return -ENODEV;
}

new_filter = *filter;
if (fattr->mask)
Expand Down Expand Up @@ -1544,6 +1552,10 @@ static ssize_t store_wakeup_protocols(struct device *device,
int i;

mutex_lock(&dev->lock);
if (!dev->registered) {
mutex_unlock(&dev->lock);
return -ENODEV;
}

allowed = dev->allowed_wakeup_protocols;

Expand Down

0 comments on commit a2e2d73

Please sign in to comment.