diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2022-04-14 08:52:39 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2022-04-14 08:52:39 +0000 |
commit | 87c14467364183f4a009dcdb3af60e8bc2a8b695 (patch) | |
tree | 8358d5638cd8a0e3811ff7f0f30d5af2988138e5 /sys/dev | |
parent | fb0d33f911baa8bc527f2443abf4533376b49245 (diff) |
drm/amdkfd: Create file descriptor after client is added to smi_clients list
From Lee Jones
3c8902bbf2ab5a15443f3daa73e8da18e7792172 in linux 5.15.y/5.15.34
e79a2398e1b2d47060474dca291542368183bc0f in mainline linux
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/drm/amd/amdkfd/kfd_smi_events.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/sys/dev/pci/drm/amd/amdkfd/kfd_smi_events.c b/sys/dev/pci/drm/amd/amdkfd/kfd_smi_events.c index ed4bc5f844c..766b3660c8c 100644 --- a/sys/dev/pci/drm/amd/amdkfd/kfd_smi_events.c +++ b/sys/dev/pci/drm/amd/amdkfd/kfd_smi_events.c @@ -270,15 +270,6 @@ int kfd_smi_event_open(struct kfd_dev *dev, uint32_t *fd) return ret; } - ret = anon_inode_getfd(kfd_smi_name, &kfd_smi_ev_fops, (void *)client, - O_RDWR); - if (ret < 0) { - kfifo_free(&client->fifo); - kfree(client); - return ret; - } - *fd = ret; - init_waitqueue_head(&client->wait_queue); spin_lock_init(&client->lock); client->events = 0; @@ -288,5 +279,20 @@ int kfd_smi_event_open(struct kfd_dev *dev, uint32_t *fd) list_add_rcu(&client->list, &dev->smi_clients); spin_unlock(&dev->smi_lock); + ret = anon_inode_getfd(kfd_smi_name, &kfd_smi_ev_fops, (void *)client, + O_RDWR); + if (ret < 0) { + spin_lock(&dev->smi_lock); + list_del_rcu(&client->list); + spin_unlock(&dev->smi_lock); + + synchronize_rcu(); + + kfifo_free(&client->fifo); + kfree(client); + return ret; + } + *fd = ret; + return 0; } |