mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
gpu: nvgpu: set file private data before installing fd
Make sure file->private_data is set before installing file into file descriptor with fd_install(). Bug 200724607 Change-Id: I03e79a3f8981f959ab5f75f442911253d166aa87 Signed-off-by: Deepak Nibade <dnibade@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2520465 Reviewed-by: Konsta Holtta <kholtta@nvidia.com> Reviewed-by: Alex Waterman <alexw@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> GVS: Gerrit_Virtual_Submit Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
ab6d4fa543
commit
c78efae5e7
@@ -621,12 +621,6 @@ static int gk20a_ctrl_alloc_as(
|
|||||||
|
|
||||||
(void) snprintf(name, sizeof(name), "nvhost-%s-fd%d", g->name, fd);
|
(void) snprintf(name, sizeof(name), "nvhost-%s-fd%d", g->name, fd);
|
||||||
|
|
||||||
file = anon_inode_getfile(name, &gk20a_as_ops, NULL, O_RDWR);
|
|
||||||
if (IS_ERR(file)) {
|
|
||||||
err = PTR_ERR(file);
|
|
||||||
goto clean_up;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = gk20a_as_alloc_share(g, args->big_page_size,
|
err = gk20a_as_alloc_share(g, args->big_page_size,
|
||||||
gk20a_as_translate_as_alloc_flags(g,
|
gk20a_as_translate_as_alloc_flags(g,
|
||||||
args->flags),
|
args->flags),
|
||||||
@@ -635,16 +629,21 @@ static int gk20a_ctrl_alloc_as(
|
|||||||
args->va_range_split,
|
args->va_range_split,
|
||||||
&as_share);
|
&as_share);
|
||||||
if (err)
|
if (err)
|
||||||
goto clean_up_file;
|
goto clean_up;
|
||||||
|
|
||||||
|
file = anon_inode_getfile(name, &gk20a_as_ops, as_share, O_RDWR);
|
||||||
|
if (IS_ERR(file)) {
|
||||||
|
err = PTR_ERR(file);
|
||||||
|
goto clean_up_as;
|
||||||
|
}
|
||||||
|
|
||||||
fd_install(fd, file);
|
fd_install(fd, file);
|
||||||
file->private_data = as_share;
|
|
||||||
|
|
||||||
args->as_fd = fd;
|
args->as_fd = fd;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
clean_up_file:
|
clean_up_as:
|
||||||
fput(file);
|
gk20a_as_release_share(as_share);
|
||||||
clean_up:
|
clean_up:
|
||||||
put_unused_fd(fd);
|
put_unused_fd(fd);
|
||||||
return err;
|
return err;
|
||||||
|
|||||||
@@ -361,17 +361,10 @@ static int gk20a_tsg_event_id_enable(struct nvgpu_tsg *tsg,
|
|||||||
(void) snprintf(name, sizeof(name), "nvgpu-event%d-fd%d",
|
(void) snprintf(name, sizeof(name), "nvgpu-event%d-fd%d",
|
||||||
event_id, local_fd);
|
event_id, local_fd);
|
||||||
|
|
||||||
file = anon_inode_getfile(name, &gk20a_event_id_ops,
|
|
||||||
NULL, O_RDWR);
|
|
||||||
if (IS_ERR(file)) {
|
|
||||||
err = PTR_ERR(file);
|
|
||||||
goto clean_up;
|
|
||||||
}
|
|
||||||
|
|
||||||
event_id_data = nvgpu_kzalloc(tsg->g, sizeof(*event_id_data));
|
event_id_data = nvgpu_kzalloc(tsg->g, sizeof(*event_id_data));
|
||||||
if (!event_id_data) {
|
if (!event_id_data) {
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
goto clean_up_file;
|
goto clean_up;
|
||||||
}
|
}
|
||||||
event_id_data->g = g;
|
event_id_data->g = g;
|
||||||
event_id_data->id = tsg->tsgid;
|
event_id_data->id = tsg->tsgid;
|
||||||
@@ -382,19 +375,25 @@ static int gk20a_tsg_event_id_enable(struct nvgpu_tsg *tsg,
|
|||||||
|
|
||||||
nvgpu_init_list_node(&event_id_data->event_id_node);
|
nvgpu_init_list_node(&event_id_data->event_id_node);
|
||||||
|
|
||||||
|
file = anon_inode_getfile(name, &gk20a_event_id_ops,
|
||||||
|
event_id_data, O_RDWR);
|
||||||
|
if (IS_ERR(file)) {
|
||||||
|
err = PTR_ERR(file);
|
||||||
|
goto clean_up_free;
|
||||||
|
}
|
||||||
|
|
||||||
nvgpu_mutex_acquire(&tsg->event_id_list_lock);
|
nvgpu_mutex_acquire(&tsg->event_id_list_lock);
|
||||||
nvgpu_list_add_tail(&event_id_data->event_id_node, &tsg->event_id_list);
|
nvgpu_list_add_tail(&event_id_data->event_id_node, &tsg->event_id_list);
|
||||||
nvgpu_mutex_release(&tsg->event_id_list_lock);
|
nvgpu_mutex_release(&tsg->event_id_list_lock);
|
||||||
|
|
||||||
fd_install(local_fd, file);
|
fd_install(local_fd, file);
|
||||||
file->private_data = event_id_data;
|
|
||||||
|
|
||||||
*fd = local_fd;
|
*fd = local_fd;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
clean_up_file:
|
clean_up_free:
|
||||||
fput(file);
|
nvgpu_kfree(g, event_id_data);
|
||||||
clean_up:
|
clean_up:
|
||||||
put_unused_fd(local_fd);
|
put_unused_fd(local_fd);
|
||||||
free_ref:
|
free_ref:
|
||||||
|
|||||||
Reference in New Issue
Block a user