drm_lease.c (6b16f5d12202a23d875915349cc031c07fe1b3ec) drm_lease.c (19f391eb05b8b005f2907ddc8f284487b446abf3)
1/*
2 * Copyright © 2017 Keith Packard <keithp@keithp.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *

--- 539 unchanged lines hidden (view full) ---

548
549 if (IS_ERR(lessee)) {
550 ret = PTR_ERR(lessee);
551 goto out_leases;
552 }
553
554 /* Clone the lessor file to create a new file for us */
555 DRM_DEBUG_LEASE("Allocating lease file\n");
1/*
2 * Copyright © 2017 Keith Packard <keithp@keithp.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *

--- 539 unchanged lines hidden (view full) ---

548
549 if (IS_ERR(lessee)) {
550 ret = PTR_ERR(lessee);
551 goto out_leases;
552 }
553
554 /* Clone the lessor file to create a new file for us */
555 DRM_DEBUG_LEASE("Allocating lease file\n");
556 path_get(&lessor_file->f_path);
557 lessee_file = alloc_file(&lessor_file->f_path,
558 lessor_file->f_mode,
559 fops_get(lessor_file->f_inode->i_fop));
560
556 lessee_file = file_clone_open(lessor_file);
561 if (IS_ERR(lessee_file)) {
562 ret = PTR_ERR(lessee_file);
563 goto out_lessee;
564 }
565
557 if (IS_ERR(lessee_file)) {
558 ret = PTR_ERR(lessee_file);
559 goto out_lessee;
560 }
561
566 /* Initialize the new file for DRM */
567 DRM_DEBUG_LEASE("Initializing the file with %p\n", lessee_file->f_op->open);
568 ret = lessee_file->f_op->open(lessee_file->f_inode, lessee_file);
569 if (ret)
570 goto out_lessee_file;
571
572 lessee_priv = lessee_file->private_data;
562 lessee_priv = lessee_file->private_data;
573
574 /* Change the file to a master one */
575 drm_master_put(&lessee_priv->master);
576 lessee_priv->master = lessee;
577 lessee_priv->is_master = 1;
578 lessee_priv->authenticated = 1;
579
580 /* Hook up the fd */
581 fd_install(fd, lessee_file);
582
583 /* Pass fd back to userspace */
584 DRM_DEBUG_LEASE("Returning fd %d id %d\n", fd, lessee->lessee_id);
585 cl->fd = fd;
586 cl->lessee_id = lessee->lessee_id;
587
588 DRM_DEBUG_LEASE("drm_mode_create_lease_ioctl succeeded\n");
589 return 0;
590
563 /* Change the file to a master one */
564 drm_master_put(&lessee_priv->master);
565 lessee_priv->master = lessee;
566 lessee_priv->is_master = 1;
567 lessee_priv->authenticated = 1;
568
569 /* Hook up the fd */
570 fd_install(fd, lessee_file);
571
572 /* Pass fd back to userspace */
573 DRM_DEBUG_LEASE("Returning fd %d id %d\n", fd, lessee->lessee_id);
574 cl->fd = fd;
575 cl->lessee_id = lessee->lessee_id;
576
577 DRM_DEBUG_LEASE("drm_mode_create_lease_ioctl succeeded\n");
578 return 0;
579
591out_lessee_file:
592 fput(lessee_file);
593
594out_lessee:
595 drm_master_put(&lessee);
596
597out_leases:
598 put_unused_fd(fd);
599 idr_destroy(&leases);
600
601 DRM_DEBUG_LEASE("drm_mode_create_lease_ioctl failed: %d\n", ret);

--- 166 unchanged lines hidden ---
580out_lessee:
581 drm_master_put(&lessee);
582
583out_leases:
584 put_unused_fd(fd);
585 idr_destroy(&leases);
586
587 DRM_DEBUG_LEASE("drm_mode_create_lease_ioctl failed: %d\n", ret);

--- 166 unchanged lines hidden ---