All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/virtio: Fix NULL vs IS_ERR checking in virtio_gpu_object_shmem_init
@ 2021-12-22  7:26 ` Miaoqian Lin
  0 siblings, 0 replies; 5+ messages in thread
From: Miaoqian Lin @ 2021-12-22  7:26 UTC (permalink / raw)
  Cc: linmq006, David Airlie, Gerd Hoffmann, Daniel Vetter,
	Gurchetan Singh, dri-devel, virtualization, linux-kernel

Since drm_prime_pages_to_sg() function return error pointers.
The drm_gem_shmem_get_sg_table() function returns error pointers too.
Using IS_ERR() to check the return value to fix this.

Fixes: f651c8b05542("drm/virtio: factor out the sg_table from virtio_gpu_object")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/gpu/drm/virtio/virtgpu_object.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c
index f648b0e24447..8bb80289672c 100644
--- a/drivers/gpu/drm/virtio/virtgpu_object.c
+++ b/drivers/gpu/drm/virtio/virtgpu_object.c
@@ -168,9 +168,9 @@ static int virtio_gpu_object_shmem_init(struct virtio_gpu_device *vgdev,
 	 * since virtio_gpu doesn't support dma-buf import from other devices.
 	 */
 	shmem->pages = drm_gem_shmem_get_sg_table(&bo->base.base);
-	if (!shmem->pages) {
+	if (IS_ERR(shmem->pages)) {
 		drm_gem_shmem_unpin(&bo->base.base);
-		return -EINVAL;
+		return PTR_ERR(shmem->pages);
 	}
 
 	if (use_dma_api) {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] drm/virtio: Fix NULL vs IS_ERR checking in virtio_gpu_object_shmem_init
@ 2021-12-22  7:26 ` Miaoqian Lin
  0 siblings, 0 replies; 5+ messages in thread
From: Miaoqian Lin @ 2021-12-22  7:26 UTC (permalink / raw)
  Cc: linmq006, David Airlie, linux-kernel, dri-devel, Gurchetan Singh,
	Gerd Hoffmann, virtualization

Since drm_prime_pages_to_sg() function return error pointers.
The drm_gem_shmem_get_sg_table() function returns error pointers too.
Using IS_ERR() to check the return value to fix this.

Fixes: f651c8b05542("drm/virtio: factor out the sg_table from virtio_gpu_object")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/gpu/drm/virtio/virtgpu_object.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c
index f648b0e24447..8bb80289672c 100644
--- a/drivers/gpu/drm/virtio/virtgpu_object.c
+++ b/drivers/gpu/drm/virtio/virtgpu_object.c
@@ -168,9 +168,9 @@ static int virtio_gpu_object_shmem_init(struct virtio_gpu_device *vgdev,
 	 * since virtio_gpu doesn't support dma-buf import from other devices.
 	 */
 	shmem->pages = drm_gem_shmem_get_sg_table(&bo->base.base);
-	if (!shmem->pages) {
+	if (IS_ERR(shmem->pages)) {
 		drm_gem_shmem_unpin(&bo->base.base);
-		return -EINVAL;
+		return PTR_ERR(shmem->pages);
 	}
 
 	if (use_dma_api) {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/virtio: Fix NULL vs IS_ERR checking in virtio_gpu_object_shmem_init
  2021-12-22  7:26 ` Miaoqian Lin
@ 2022-01-07 23:34   ` Gurchetan Singh
  -1 siblings, 0 replies; 5+ messages in thread
From: Gurchetan Singh @ 2022-01-07 23:34 UTC (permalink / raw)
  To: Miaoqian Lin
  Cc: David Airlie, open list, ML dri-devel,
	open list:VIRTIO GPU DRIVER, Daniel Vetter


[-- Attachment #1.1: Type: text/plain, Size: 1348 bytes --]

On Tue, Dec 21, 2021 at 11:26 PM Miaoqian Lin <linmq006@gmail.com> wrote:

> Since drm_prime_pages_to_sg() function return error pointers.
> The drm_gem_shmem_get_sg_table() function returns error pointers too.
> Using IS_ERR() to check the return value to fix this.
>
> Fixes: f651c8b05542("drm/virtio: factor out the sg_table from
> virtio_gpu_object")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
>

Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>


> ---
>  drivers/gpu/drm/virtio/virtgpu_object.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c
> b/drivers/gpu/drm/virtio/virtgpu_object.c
> index f648b0e24447..8bb80289672c 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_object.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_object.c
> @@ -168,9 +168,9 @@ static int virtio_gpu_object_shmem_init(struct
> virtio_gpu_device *vgdev,
>          * since virtio_gpu doesn't support dma-buf import from other
> devices.
>          */
>         shmem->pages = drm_gem_shmem_get_sg_table(&bo->base.base);
> -       if (!shmem->pages) {
> +       if (IS_ERR(shmem->pages)) {
>                 drm_gem_shmem_unpin(&bo->base.base);
> -               return -EINVAL;
> +               return PTR_ERR(shmem->pages);
>         }
>
>         if (use_dma_api) {
> --
> 2.17.1
>
>

[-- Attachment #1.2: Type: text/html, Size: 2138 bytes --]

[-- Attachment #2: Type: text/plain, Size: 183 bytes --]

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/virtio: Fix NULL vs IS_ERR checking in virtio_gpu_object_shmem_init
@ 2022-01-07 23:34   ` Gurchetan Singh
  0 siblings, 0 replies; 5+ messages in thread
From: Gurchetan Singh @ 2022-01-07 23:34 UTC (permalink / raw)
  To: Miaoqian Lin
  Cc: David Airlie, open list, ML dri-devel,
	open list:VIRTIO GPU DRIVER, Gerd Hoffmann

[-- Attachment #1: Type: text/plain, Size: 1348 bytes --]

On Tue, Dec 21, 2021 at 11:26 PM Miaoqian Lin <linmq006@gmail.com> wrote:

> Since drm_prime_pages_to_sg() function return error pointers.
> The drm_gem_shmem_get_sg_table() function returns error pointers too.
> Using IS_ERR() to check the return value to fix this.
>
> Fixes: f651c8b05542("drm/virtio: factor out the sg_table from
> virtio_gpu_object")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
>

Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>


> ---
>  drivers/gpu/drm/virtio/virtgpu_object.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c
> b/drivers/gpu/drm/virtio/virtgpu_object.c
> index f648b0e24447..8bb80289672c 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_object.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_object.c
> @@ -168,9 +168,9 @@ static int virtio_gpu_object_shmem_init(struct
> virtio_gpu_device *vgdev,
>          * since virtio_gpu doesn't support dma-buf import from other
> devices.
>          */
>         shmem->pages = drm_gem_shmem_get_sg_table(&bo->base.base);
> -       if (!shmem->pages) {
> +       if (IS_ERR(shmem->pages)) {
>                 drm_gem_shmem_unpin(&bo->base.base);
> -               return -EINVAL;
> +               return PTR_ERR(shmem->pages);
>         }
>
>         if (use_dma_api) {
> --
> 2.17.1
>
>

[-- Attachment #2: Type: text/html, Size: 2138 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/virtio: Fix NULL vs IS_ERR checking in virtio_gpu_object_shmem_init
@ 2022-01-02  0:59 kernel test robot
  0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2022-01-02  0:59 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 16723 bytes --]

CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
In-Reply-To: <20211222072649.18169-1-linmq006@gmail.com>
References: <20211222072649.18169-1-linmq006@gmail.com>
TO: Miaoqian Lin <linmq006@gmail.com>
CC: linmq006(a)gmail.com
CC: David Airlie <airlied@linux.ie>
CC: linux-kernel(a)vger.kernel.org
CC: dri-devel(a)lists.freedesktop.org
CC: Gurchetan Singh <gurchetansingh@chromium.org>
CC: Gerd Hoffmann <kraxel@redhat.com>
CC: virtualization(a)lists.linux-foundation.org

Hi Miaoqian,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on v5.16-rc6]
[cannot apply to drm/drm-next next-20211224]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Miaoqian-Lin/drm-virtio-Fix-NULL-vs-IS_ERR-checking-in-virtio_gpu_object_shmem_init/20211222-152857
base:    a7904a538933c525096ca2ccde1e60d0ee62c08e
:::::: branch date: 11 days ago
:::::: commit date: 11 days ago
config: arm-randconfig-c002-20211228 (https://download.01.org/0day-ci/archive/20220102/202201020823.RqskJWLZ-lkp(a)intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project cd284b7ac0615afc6e0f1a30da2777e361de27a3)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # https://github.com/0day-ci/linux/commit/fa5dcbfe5084bcdae76ccb313f3099bf06063c57
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Miaoqian-Lin/drm-virtio-Fix-NULL-vs-IS_ERR-checking-in-virtio_gpu_object_shmem_init/20211222-152857
        git checkout fa5dcbfe5084bcdae76ccb313f3099bf06063c57
        # save the config file to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm clang-analyzer 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


clang-analyzer warnings: (new ones prefixed by >>)
           if (error || !*bpp || !tp)
               ^~~~~
   fs/xfs/libxfs/xfs_da_btree.c:380:6: note: Left side of '||' is false
   fs/xfs/libxfs/xfs_da_btree.c:380:21: note: Left side of '||' is true
           if (error || !*bpp || !tp)
                              ^
   fs/xfs/libxfs/xfs_da_btree.c:381:3: note: Returning zero (loaded from 'error'), which participates in a condition later
                   return error;
                   ^~~~~~~~~~~~
   fs/xfs/libxfs/xfs_da_btree.c:1604:11: note: Returning from 'xfs_da3_node_read'
                   error = xfs_da3_node_read(args->trans, args->dp, blkno,
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/xfs/libxfs/xfs_da_btree.c:1606:7: note: 'error' is 0
                   if (error) {
                       ^~~~~
   fs/xfs/libxfs/xfs_da_btree.c:1606:3: note: Taking false branch
                   if (error) {
                   ^
   fs/xfs/libxfs/xfs_da_btree.c:1611:10: note: Access to field 'b_addr' results in a dereference of a null pointer (loaded from field 'bp')
                   curr = blk->bp->b_addr;
                          ^    ~~
   fs/xfs/libxfs/xfs_da_btree.c:2203:22: warning: Dereference of null pointer [clang-analyzer-core.NullDereference]
           if (got != count || mapp[0].br_startoff != *bno ||
                               ^~~~~~~~~~~~~~~~~~~
   fs/xfs/libxfs/xfs_da_btree.c:2153:6: note: Assuming 'error' is 0
           if (error)
               ^~~~~
   fs/xfs/libxfs/xfs_da_btree.c:2153:2: note: Taking false branch
           if (error)
           ^
   fs/xfs/libxfs/xfs_da_btree.c:2163:6: note: Assuming 'error' is 0
           if (error)
               ^~~~~
   fs/xfs/libxfs/xfs_da_btree.c:2163:2: note: Taking false branch
           if (error)
           ^
   fs/xfs/libxfs/xfs_da_btree.c:2166:9: note: Assuming 'nmap' is <= 1
           ASSERT(nmap <= 1);
                  ^
   fs/xfs/xfs_linux.h:207:10: note: expanded from macro 'ASSERT'
           (likely(expr) ? (void)0 : assfail(NULL, #expr, __FILE__, __LINE__))
                   ^~~~
   include/linux/compiler.h:45:39: note: expanded from macro 'likely'
   #  define likely(x)     (__branch_check__(x, 1, __builtin_constant_p(x)))
                                             ^
   include/linux/compiler.h:33:34: note: expanded from macro '__branch_check__'
                           ______r = __builtin_expect(!!(x), expect);      \
                                                         ^
   fs/xfs/libxfs/xfs_da_btree.c:2166:9: note: 'nmap' is <= 1
           ASSERT(nmap <= 1);
                  ^
   fs/xfs/xfs_linux.h:207:10: note: expanded from macro 'ASSERT'
           (likely(expr) ? (void)0 : assfail(NULL, #expr, __FILE__, __LINE__))
                   ^~~~
   include/linux/compiler.h:45:66: note: expanded from macro 'likely'
   #  define likely(x)     (__branch_check__(x, 1, __builtin_constant_p(x)))
                                                                        ^
   include/linux/compiler.h:35:19: note: expanded from macro '__branch_check__'
                                                expect, is_constant);      \
                                                        ^~~~~~~~~~~
   fs/xfs/libxfs/xfs_da_btree.c:2166:2: note: '?' condition is true
           ASSERT(nmap <= 1);
           ^
   fs/xfs/xfs_linux.h:207:3: note: expanded from macro 'ASSERT'
           (likely(expr) ? (void)0 : assfail(NULL, #expr, __FILE__, __LINE__))
            ^
   include/linux/compiler.h:45:21: note: expanded from macro 'likely'
   #  define likely(x)     (__branch_check__(x, 1, __builtin_constant_p(x)))
                           ^
   fs/xfs/libxfs/xfs_da_btree.c:2167:6: note: Assuming 'nmap' is not equal to 1
           if (nmap == 1) {
               ^~~~~~~~~
   fs/xfs/libxfs/xfs_da_btree.c:2167:2: note: Taking false branch
           if (nmap == 1) {
           ^
   fs/xfs/libxfs/xfs_da_btree.c:2170:13: note: Assuming 'nmap' is not equal to 0
           } else if (nmap == 0 && count > 1) {
                      ^~~~~~~~~
   fs/xfs/libxfs/xfs_da_btree.c:2170:23: note: Left side of '&&' is false
           } else if (nmap == 0 && count > 1) {
                                ^
   fs/xfs/libxfs/xfs_da_btree.c:2195:3: note: Null pointer value stored to 'mapp'
                   mapp = NULL;
                   ^~~~~~~~~~~
   fs/xfs/libxfs/xfs_da_btree.c:2201:2: note: Loop condition is false. Execution continues on line 2203
           for (i = 0, got = 0; i < mapi; i++)
           ^
   fs/xfs/libxfs/xfs_da_btree.c:2203:6: note: Assuming 'got' is equal to 'count'
           if (got != count || mapp[0].br_startoff != *bno ||
               ^~~~~~~~~~~~
   fs/xfs/libxfs/xfs_da_btree.c:2203:6: note: Left side of '||' is false
   fs/xfs/libxfs/xfs_da_btree.c:2203:22: note: Dereference of null pointer
           if (got != count || mapp[0].br_startoff != *bno ||
                               ^~~~~~~~~~~~~~~~~~~
   Suppressed 16 warnings (16 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   15 warnings generated.
   Suppressed 15 warnings (15 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   19 warnings generated.
>> drivers/gpu/drm/virtio/virtgpu_object.c:253:3: warning: Use of memory after it is freed [clang-analyzer-unix.Malloc]
                   return ret;
                   ^      ~~~
   drivers/gpu/drm/virtio/virtgpu_object.c:227:2: note: Taking false branch
           if (IS_ERR(shmem_obj))
           ^
   drivers/gpu/drm/virtio/virtgpu_object.c:232:6: note: 'ret' is >= 0
           if (ret < 0)
               ^~~
   drivers/gpu/drm/virtio/virtgpu_object.c:232:2: note: Taking false branch
           if (ret < 0)
           ^
   drivers/gpu/drm/virtio/virtgpu_object.c:237:6: note: Assuming 'fence' is null
           if (fence) {
               ^~~~~
   drivers/gpu/drm/virtio/virtgpu_object.c:237:2: note: Taking false branch
           if (fence) {
           ^
   drivers/gpu/drm/virtio/virtgpu_object.c:250:6: note: Assuming 'ret' is not equal to 0
           if (ret != 0) {
               ^~~~~~~~
   drivers/gpu/drm/virtio/virtgpu_object.c:250:2: note: Taking true branch
           if (ret != 0) {
           ^
   drivers/gpu/drm/virtio/virtgpu_object.c:252:3: note: Calling 'virtio_gpu_free_object'
                   virtio_gpu_free_object(&shmem_obj->base);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/virtio/virtgpu_object.c:106:6: note: Assuming field 'created' is false
           if (bo->created) {
               ^~~~~~~~~~~
   drivers/gpu/drm/virtio/virtgpu_object.c:106:2: note: Taking false branch
           if (bo->created) {
           ^
   drivers/gpu/drm/virtio/virtgpu_object.c:112:2: note: Calling 'virtio_gpu_cleanup_object'
           virtio_gpu_cleanup_object(bo);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/virtio/virtgpu_object.c:69:6: note: Assuming the condition is true
           if (virtio_gpu_is_shmem(bo)) {
               ^~~~~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/virtio/virtgpu_object.c:69:2: note: Taking true branch
           if (virtio_gpu_is_shmem(bo)) {
           ^
   drivers/gpu/drm/virtio/virtgpu_object.c:72:14: note: Field 'pages' is non-null
                   if (shmem->pages) {
                              ^
   drivers/gpu/drm/virtio/virtgpu_object.c:72:3: note: Taking true branch
                   if (shmem->pages) {
                   ^
   drivers/gpu/drm/virtio/virtgpu_object.c:73:8: note: Assuming field 'mapped' is 0
                           if (shmem->mapped) {
                               ^~~~~~~~~~~~~
   drivers/gpu/drm/virtio/virtgpu_object.c:73:4: note: Taking false branch
                           if (shmem->mapped) {
                           ^
   drivers/gpu/drm/virtio/virtgpu_object.c:80:4: note: Memory is released
                           kfree(shmem->pages);
                           ^~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/virtio/virtgpu_object.c:112:2: note: Returning; memory was released
           virtio_gpu_cleanup_object(bo);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/virtio/virtgpu_object.c:252:3: note: Returning; memory was released
                   virtio_gpu_free_object(&shmem_obj->base);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/virtio/virtgpu_object.c:253:3: note: Use of memory after it is freed
                   return ret;
                   ^      ~~~
   drivers/gpu/drm/virtio/virtgpu_object.c:260:3: warning: 4th function call argument is an uninitialized value [clang-analyzer-core.CallAndMessage]
                   virtio_gpu_cmd_resource_create_blob(vgdev, bo, params,
                   ^
   drivers/gpu/drm/virtio/virtgpu_object.c:219:2: note: 'ents' declared without an initial value
           struct virtio_gpu_mem_entry *ents;
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/virtio/virtgpu_object.c:227:6: note: Calling 'IS_ERR'
           if (IS_ERR(shmem_obj))
               ^~~~~~~~~~~~~~~~~
   include/linux/err.h:36:9: note: Assuming the condition is false
           return IS_ERR_VALUE((unsigned long)ptr);
                  ^
   include/linux/err.h:22:34: note: expanded from macro 'IS_ERR_VALUE'
   #define IS_ERR_VALUE(x) unlikely((unsigned long)(void *)(x) >= (unsigned long)-MAX_ERRNO)
                           ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:48:41: note: expanded from macro 'unlikely'
   #  define unlikely(x)   (__branch_check__(x, 0, __builtin_constant_p(x)))
                            ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:33:34: note: expanded from macro '__branch_check__'
                           ______r = __builtin_expect(!!(x), expect);      \
                                                         ^
   include/linux/err.h:36:2: note: Returning zero, which participates in a condition later
           return IS_ERR_VALUE((unsigned long)ptr);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/virtio/virtgpu_object.c:227:6: note: Returning from 'IS_ERR'
           if (IS_ERR(shmem_obj))
               ^~~~~~~~~~~~~~~~~
   drivers/gpu/drm/virtio/virtgpu_object.c:227:2: note: Taking false branch
           if (IS_ERR(shmem_obj))
           ^
   drivers/gpu/drm/virtio/virtgpu_object.c:232:6: note: 'ret' is >= 0
           if (ret < 0)
               ^~~
   drivers/gpu/drm/virtio/virtgpu_object.c:232:2: note: Taking false branch
           if (ret < 0)

vim +253 drivers/gpu/drm/virtio/virtgpu_object.c

2f2aa13724d568 Gerd Hoffmann  2020-02-07  210  
dc5698e80cf724 Dave Airlie    2013-09-09  211  int virtio_gpu_object_create(struct virtio_gpu_device *vgdev,
4441235f9566e6 Gerd Hoffmann  2019-03-18  212  			     struct virtio_gpu_object_params *params,
530b28426a94b8 Gerd Hoffmann  2019-03-18  213  			     struct virtio_gpu_object **bo_ptr,
530b28426a94b8 Gerd Hoffmann  2019-03-18  214  			     struct virtio_gpu_fence *fence)
dc5698e80cf724 Dave Airlie    2013-09-09  215  {
e2324300f427ff Gerd Hoffmann  2019-08-29  216  	struct virtio_gpu_object_array *objs = NULL;
c66df701e783bc Gerd Hoffmann  2019-08-29  217  	struct drm_gem_shmem_object *shmem_obj;
dc5698e80cf724 Dave Airlie    2013-09-09  218  	struct virtio_gpu_object *bo;
2f2aa13724d568 Gerd Hoffmann  2020-02-07  219  	struct virtio_gpu_mem_entry *ents;
2f2aa13724d568 Gerd Hoffmann  2020-02-07  220  	unsigned int nents;
dc5698e80cf724 Dave Airlie    2013-09-09  221  	int ret;
dc5698e80cf724 Dave Airlie    2013-09-09  222  
dc5698e80cf724 Dave Airlie    2013-09-09  223  	*bo_ptr = NULL;
dc5698e80cf724 Dave Airlie    2013-09-09  224  
c66df701e783bc Gerd Hoffmann  2019-08-29  225  	params->size = roundup(params->size, PAGE_SIZE);
c66df701e783bc Gerd Hoffmann  2019-08-29  226  	shmem_obj = drm_gem_shmem_create(vgdev->ddev, params->size);
c66df701e783bc Gerd Hoffmann  2019-08-29  227  	if (IS_ERR(shmem_obj))
c66df701e783bc Gerd Hoffmann  2019-08-29  228  		return PTR_ERR(shmem_obj);
c66df701e783bc Gerd Hoffmann  2019-08-29  229  	bo = gem_to_virtio_gpu_obj(&shmem_obj->base);
dc5698e80cf724 Dave Airlie    2013-09-09  230  
556c62e85f9b97 Matthew Wilcox 2018-10-30  231  	ret = virtio_gpu_resource_id_get(vgdev, &bo->hw_res_handle);
e2324300f427ff Gerd Hoffmann  2019-08-29  232  	if (ret < 0)
e2324300f427ff Gerd Hoffmann  2019-08-29  233  		goto err_free_gem;
e2324300f427ff Gerd Hoffmann  2019-08-29  234  
530b28426a94b8 Gerd Hoffmann  2019-03-18  235  	bo->dumb = params->dumb;
530b28426a94b8 Gerd Hoffmann  2019-03-18  236  
e2324300f427ff Gerd Hoffmann  2019-08-29  237  	if (fence) {
e2324300f427ff Gerd Hoffmann  2019-08-29  238  		ret = -ENOMEM;
e2324300f427ff Gerd Hoffmann  2019-08-29  239  		objs = virtio_gpu_array_alloc(1);
e2324300f427ff Gerd Hoffmann  2019-08-29  240  		if (!objs)
e2324300f427ff Gerd Hoffmann  2019-08-29  241  			goto err_put_id;
c66df701e783bc Gerd Hoffmann  2019-08-29  242  		virtio_gpu_array_add_obj(objs, &bo->base.base);
e2324300f427ff Gerd Hoffmann  2019-08-29  243  
e2324300f427ff Gerd Hoffmann  2019-08-29  244  		ret = virtio_gpu_array_lock_resv(objs);
e2324300f427ff Gerd Hoffmann  2019-08-29  245  		if (ret != 0)
e2324300f427ff Gerd Hoffmann  2019-08-29  246  			goto err_put_objs;
e2324300f427ff Gerd Hoffmann  2019-08-29  247  	}
e2324300f427ff Gerd Hoffmann  2019-08-29  248  
2f2aa13724d568 Gerd Hoffmann  2020-02-07  249  	ret = virtio_gpu_object_shmem_init(vgdev, bo, &ents, &nents);
2f2aa13724d568 Gerd Hoffmann  2020-02-07  250  	if (ret != 0) {
377f8331d0565e xndcn          2021-03-05  251  		virtio_gpu_array_put_free(objs);
2f2aa13724d568 Gerd Hoffmann  2020-02-07  252  		virtio_gpu_free_object(&shmem_obj->base);
2f2aa13724d568 Gerd Hoffmann  2020-02-07 @253  		return ret;

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-01-07 23:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-22  7:26 [PATCH] drm/virtio: Fix NULL vs IS_ERR checking in virtio_gpu_object_shmem_init Miaoqian Lin
2021-12-22  7:26 ` Miaoqian Lin
2022-01-07 23:34 ` Gurchetan Singh
2022-01-07 23:34   ` Gurchetan Singh
2022-01-02  0:59 kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.