diff options
author | Deepak Nibade <dnibade@nvidia.com> | 2021-04-26 05:27:32 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2021-06-04 03:08:57 -0400 |
commit | cbad9503a78c23336a32172dd701b73760969ff0 (patch) | |
tree | 1e2c22db5e2c634b6259d9ab10b1309eec8d1597 /drivers/gpu/nvgpu | |
parent | 34993e4f7b0d47620e88ba64a6d7c67330d97e35 (diff) |
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
Bug 200725718
Change-Id: I03e79a3f8981f959ab5f75f442911253d166aa87
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2520465
(cherry picked from commit c78efae5e721287a3c7e9c9ca045220d6e433a30)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2535099
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Harsh Sinha <hsinha@nvidia.com>
Reviewed-by: Thomas Steinle <tsteinle@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: Byungkuk Seo <bseo@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu')
-rw-r--r-- | drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c | 19 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/os/linux/ioctl_tsg.c | 19 |
2 files changed, 17 insertions, 21 deletions
diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c b/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c index 94162b4f..f71921cb 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c | |||
@@ -488,27 +488,26 @@ static int gk20a_ctrl_alloc_as( | |||
488 | 488 | ||
489 | snprintf(name, sizeof(name), "nvhost-%s-fd%d", g->name, fd); | 489 | snprintf(name, sizeof(name), "nvhost-%s-fd%d", g->name, fd); |
490 | 490 | ||
491 | file = anon_inode_getfile(name, l->as_dev.cdev.ops, NULL, O_RDWR); | ||
492 | if (IS_ERR(file)) { | ||
493 | err = PTR_ERR(file); | ||
494 | goto clean_up; | ||
495 | } | ||
496 | |||
497 | err = gk20a_as_alloc_share(g, args->big_page_size, | 491 | err = gk20a_as_alloc_share(g, args->big_page_size, |
498 | gk20a_as_translate_as_alloc_flags(g, | 492 | gk20a_as_translate_as_alloc_flags(g, |
499 | args->flags), | 493 | args->flags), |
500 | &as_share); | 494 | &as_share); |
501 | if (err) | 495 | if (err) |
502 | goto clean_up_file; | 496 | goto clean_up; |
497 | |||
498 | file = anon_inode_getfile(name, l->as_dev.cdev.ops, as_share, O_RDWR); | ||
499 | if (IS_ERR(file)) { | ||
500 | err = PTR_ERR(file); | ||
501 | goto clean_up_as; | ||
502 | } | ||
503 | 503 | ||
504 | fd_install(fd, file); | 504 | fd_install(fd, file); |
505 | file->private_data = as_share; | ||
506 | 505 | ||
507 | args->as_fd = fd; | 506 | args->as_fd = fd; |
508 | return 0; | 507 | return 0; |
509 | 508 | ||
510 | clean_up_file: | 509 | clean_up_as: |
511 | fput(file); | 510 | gk20a_as_release_share(as_share); |
512 | clean_up: | 511 | clean_up: |
513 | put_unused_fd(fd); | 512 | put_unused_fd(fd); |
514 | return err; | 513 | return err; |
diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_tsg.c b/drivers/gpu/nvgpu/os/linux/ioctl_tsg.c index 915a173a..296b02b2 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_tsg.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_tsg.c | |||
@@ -310,17 +310,10 @@ static int gk20a_tsg_event_id_enable(struct tsg_gk20a *tsg, | |||
310 | snprintf(name, sizeof(name), "nvgpu-event%d-fd%d", | 310 | snprintf(name, sizeof(name), "nvgpu-event%d-fd%d", |
311 | event_id, local_fd); | 311 | event_id, local_fd); |
312 | 312 | ||
313 | file = anon_inode_getfile(name, &gk20a_event_id_ops, | ||
314 | NULL, O_RDWR); | ||
315 | if (IS_ERR(file)) { | ||
316 | err = PTR_ERR(file); | ||
317 | goto clean_up; | ||
318 | } | ||
319 | |||
320 | event_id_data = nvgpu_kzalloc(tsg->g, sizeof(*event_id_data)); | 313 | event_id_data = nvgpu_kzalloc(tsg->g, sizeof(*event_id_data)); |
321 | if (!event_id_data) { | 314 | if (!event_id_data) { |
322 | err = -ENOMEM; | 315 | err = -ENOMEM; |
323 | goto clean_up_file; | 316 | goto clean_up; |
324 | } | 317 | } |
325 | event_id_data->g = g; | 318 | event_id_data->g = g; |
326 | event_id_data->id = tsg->tsgid; | 319 | event_id_data->id = tsg->tsgid; |
@@ -333,12 +326,18 @@ static int gk20a_tsg_event_id_enable(struct tsg_gk20a *tsg, | |||
333 | 326 | ||
334 | nvgpu_init_list_node(&event_id_data->event_id_node); | 327 | nvgpu_init_list_node(&event_id_data->event_id_node); |
335 | 328 | ||
329 | file = anon_inode_getfile(name, &gk20a_event_id_ops, | ||
330 | event_id_data, O_RDWR); | ||
331 | if (IS_ERR(file)) { | ||
332 | err = PTR_ERR(file); | ||
333 | goto clean_up_free; | ||
334 | } | ||
335 | |||
336 | nvgpu_mutex_acquire(&tsg->event_id_list_lock); | 336 | nvgpu_mutex_acquire(&tsg->event_id_list_lock); |
337 | nvgpu_list_add_tail(&event_id_data->event_id_node, &tsg->event_id_list); | 337 | nvgpu_list_add_tail(&event_id_data->event_id_node, &tsg->event_id_list); |
338 | nvgpu_mutex_release(&tsg->event_id_list_lock); | 338 | nvgpu_mutex_release(&tsg->event_id_list_lock); |
339 | 339 | ||
340 | fd_install(local_fd, file); | 340 | fd_install(local_fd, file); |
341 | file->private_data = event_id_data; | ||
342 | 341 | ||
343 | *fd = local_fd; | 342 | *fd = local_fd; |
344 | 343 | ||
@@ -346,8 +345,6 @@ static int gk20a_tsg_event_id_enable(struct tsg_gk20a *tsg, | |||
346 | 345 | ||
347 | clean_up_free: | 346 | clean_up_free: |
348 | nvgpu_kfree(g, event_id_data); | 347 | nvgpu_kfree(g, event_id_data); |
349 | clean_up_file: | ||
350 | fput(file); | ||
351 | clean_up: | 348 | clean_up: |
352 | put_unused_fd(local_fd); | 349 | put_unused_fd(local_fd); |
353 | free_ref: | 350 | free_ref: |