@@ -4536,7 +4536,7 @@ enum dxg_sharedobject_type {
45364536};
45374537
45384538static int get_object_fd (enum dxg_sharedobject_type type ,
4539- void * object , int * fdout )
4539+ void * object , int * fdout , struct file * * filp )
45404540{
45414541 struct file * file ;
45424542 int fd ;
@@ -4565,8 +4565,8 @@ static int get_object_fd(enum dxg_sharedobject_type type,
45654565 return - ENOTRECOVERABLE ;
45664566 }
45674567
4568- fd_install (fd , file );
45694568 * fdout = fd ;
4569+ * filp = file ;
45704570 return 0 ;
45714571}
45724572
@@ -4581,6 +4581,7 @@ dxgkio_share_objects(struct dxgprocess *process, void *__user inargs)
45814581 struct dxgsharedresource * shared_resource = NULL ;
45824582 struct d3dkmthandle * handles = NULL ;
45834583 int object_fd = -1 ;
4584+ struct file * filp = NULL ;
45844585 void * obj = NULL ;
45854586 u32 handle_size ;
45864587 int ret ;
@@ -4660,7 +4661,7 @@ dxgkio_share_objects(struct dxgprocess *process, void *__user inargs)
46604661 switch (object_type ) {
46614662 case HMGRENTRY_TYPE_DXGSYNCOBJECT :
46624663 ret = get_object_fd (DXG_SHARED_SYNCOBJECT , shared_syncobj ,
4663- & object_fd );
4664+ & object_fd , & filp );
46644665 if (ret < 0 ) {
46654666 DXG_ERR ("get_object_fd failed for sync object" );
46664667 goto cleanup ;
@@ -4675,7 +4676,7 @@ dxgkio_share_objects(struct dxgprocess *process, void *__user inargs)
46754676 break ;
46764677 case HMGRENTRY_TYPE_DXGRESOURCE :
46774678 ret = get_object_fd (DXG_SHARED_RESOURCE , shared_resource ,
4678- & object_fd );
4679+ & object_fd , & filp );
46794680 if (ret < 0 ) {
46804681 DXG_ERR ("get_object_fd failed for resource" );
46814682 goto cleanup ;
@@ -4708,10 +4709,15 @@ dxgkio_share_objects(struct dxgprocess *process, void *__user inargs)
47084709 if (ret ) {
47094710 DXG_ERR ("failed to copy shared handle" );
47104711 ret = - EFAULT ;
4712+ goto cleanup ;
47114713 }
47124714
4715+ fd_install (object_fd , filp );
4716+
47134717cleanup :
47144718 if (ret < 0 ) {
4719+ if (filp )
4720+ fput (filp );
47154721 if (object_fd >= 0 )
47164722 put_unused_fd (object_fd );
47174723 }
0 commit comments