Skip to content

Commit 8e1ffb2

Browse files
tweejgregkh
authored andcommitted
drm/syncobj: Fix syncobj leak in drm_syncobj_eventfd_ioctl
commit 8c7c44b upstream. A syncobj reference is taken in drm_syncobj_find, but not released if eventfd_ctx_fdget or kzalloc fails. Put the reference in these error paths. Reported-by: Xingyu Jin <xingyuj@google.com> Fixes: c7a4722 ("drm/syncobj: add IOCTL to register an eventfd") Signed-off-by: T.J. Mercier <tjmercier@google.com> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com> Reviewed-by. Christian König <christian.koenig@amd.com> CC: stable@vger.kernel.org # 6.6+ Link: https://patchwork.freedesktop.org/patch/msgid/20240909205400.3498337-1-tjmercier@google.com Signed-off-by: Christian König <christian.koenig@amd.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 28425a1 commit 8e1ffb2

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

drivers/gpu/drm/drm_syncobj.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,6 +1421,7 @@ drm_syncobj_eventfd_ioctl(struct drm_device *dev, void *data,
14211421
struct drm_syncobj *syncobj;
14221422
struct eventfd_ctx *ev_fd_ctx;
14231423
struct syncobj_eventfd_entry *entry;
1424+
int ret;
14241425

14251426
if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ_TIMELINE))
14261427
return -EOPNOTSUPP;
@@ -1436,13 +1437,15 @@ drm_syncobj_eventfd_ioctl(struct drm_device *dev, void *data,
14361437
return -ENOENT;
14371438

14381439
ev_fd_ctx = eventfd_ctx_fdget(args->fd);
1439-
if (IS_ERR(ev_fd_ctx))
1440-
return PTR_ERR(ev_fd_ctx);
1440+
if (IS_ERR(ev_fd_ctx)) {
1441+
ret = PTR_ERR(ev_fd_ctx);
1442+
goto err_fdget;
1443+
}
14411444

14421445
entry = kzalloc(sizeof(*entry), GFP_KERNEL);
14431446
if (!entry) {
1444-
eventfd_ctx_put(ev_fd_ctx);
1445-
return -ENOMEM;
1447+
ret = -ENOMEM;
1448+
goto err_kzalloc;
14461449
}
14471450
entry->syncobj = syncobj;
14481451
entry->ev_fd_ctx = ev_fd_ctx;
@@ -1453,6 +1456,12 @@ drm_syncobj_eventfd_ioctl(struct drm_device *dev, void *data,
14531456
drm_syncobj_put(syncobj);
14541457

14551458
return 0;
1459+
1460+
err_kzalloc:
1461+
eventfd_ctx_put(ev_fd_ctx);
1462+
err_fdget:
1463+
drm_syncobj_put(syncobj);
1464+
return ret;
14561465
}
14571466

14581467
int

0 commit comments

Comments
 (0)