Skip to content

Commit a2e2d73

Browse files
seanyoungmchehab
authored andcommitted
media: rc: do not access device via sysfs after rc_unregister_device()
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: <[email protected]> # 4.16+ Signed-off-by: Sean Young <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 4f0835d commit a2e2d73

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/media/rc/rc-main.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,6 +1292,10 @@ static ssize_t store_protocols(struct device *device,
12921292
}
12931293

12941294
mutex_lock(&dev->lock);
1295+
if (!dev->registered) {
1296+
mutex_unlock(&dev->lock);
1297+
return -ENODEV;
1298+
}
12951299

12961300
old_protocols = *current_protocols;
12971301
new_protocols = old_protocols;
@@ -1430,6 +1434,10 @@ static ssize_t store_filter(struct device *device,
14301434
return -EINVAL;
14311435

14321436
mutex_lock(&dev->lock);
1437+
if (!dev->registered) {
1438+
mutex_unlock(&dev->lock);
1439+
return -ENODEV;
1440+
}
14331441

14341442
new_filter = *filter;
14351443
if (fattr->mask)
@@ -1544,6 +1552,10 @@ static ssize_t store_wakeup_protocols(struct device *device,
15441552
int i;
15451553

15461554
mutex_lock(&dev->lock);
1555+
if (!dev->registered) {
1556+
mutex_unlock(&dev->lock);
1557+
return -ENODEV;
1558+
}
15471559

15481560
allowed = dev->allowed_wakeup_protocols;
15491561

0 commit comments

Comments
 (0)