Skip to content

Commit 5b1834d

Browse files
Tvrtko UrsulinChristianKoenigAMD
authored andcommitted
drm/fdinfo: Protect against driver unbind
If we unbind a driver from the PCI device with an active DRM client, subsequent read of the fdinfo data associated with the file descriptor in question will not end well. Protect the path with a drm_dev_enter/exit() pair. Signed-off-by: Tvrtko Ursulin <[email protected]> Cc: Christian König <[email protected]> Cc: Lucas De Marchi <[email protected]> Cc: Rodrigo Vivi <[email protected]> Cc: Umesh Nerlige Ramappa <[email protected]> Reviewed-by: Christian König <[email protected]> Fixes: 3f09a0c ("drm: Add common fdinfo helper") Cc: <[email protected]> # v6.5+ Signed-off-by: Christian König <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 7604748 commit 5b1834d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/gpu/drm/drm_file.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,10 @@ void drm_show_fdinfo(struct seq_file *m, struct file *f)
964964
struct drm_file *file = f->private_data;
965965
struct drm_device *dev = file->minor->dev;
966966
struct drm_printer p = drm_seq_file_printer(m);
967+
int idx;
968+
969+
if (!drm_dev_enter(dev, &idx))
970+
return;
967971

968972
drm_printf(&p, "drm-driver:\t%s\n", dev->driver->name);
969973
drm_printf(&p, "drm-client-id:\t%llu\n", file->client_id);
@@ -983,6 +987,8 @@ void drm_show_fdinfo(struct seq_file *m, struct file *f)
983987

984988
if (dev->driver->show_fdinfo)
985989
dev->driver->show_fdinfo(&p, file);
990+
991+
drm_dev_exit(idx);
986992
}
987993
EXPORT_SYMBOL(drm_show_fdinfo);
988994

0 commit comments

Comments
 (0)