Discussion:
[PATCH V1][libva-intel-driver] Return if the surface bo is NULL
(too old to reply)
peng.chen
2016-12-30 08:08:36 UTC
Permalink
Signed-off-by: peng.chen <***@intel.com>
---
src/i965_drv_video.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c
index bf59374..ded3d93 100644
--- a/src/i965_drv_video.c
+++ b/src/i965_drv_video.c
@@ -1210,7 +1210,7 @@ VAStatus i965_QueryConfigAttributes(VADriverContextP ctx,
void
i965_destroy_surface_storage(struct object_surface *obj_surface)
{
- if (!obj_surface)
+ if (!obj_surface || !obj_surface->bo)
return;

dri_bo_unreference(obj_surface->bo);
--
1.9.1
Zhao Yakui
2016-12-30 08:18:01 UTC
Permalink
In fact the dri_bo_unreference function can handle the scenario that bo
is NULL.

Of course it also looks good to me that the explicit check is added in
the i965_destroy_surface_storage.

Add: Reviewed-by: Zhao Yakui <***@intel.com>

Thanks
Post by peng.chen
---
src/i965_drv_video.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c
index bf59374..ded3d93 100644
--- a/src/i965_drv_video.c
+++ b/src/i965_drv_video.c
@@ -1210,7 +1210,7 @@ VAStatus i965_QueryConfigAttributes(VADriverContextP ctx,
void
i965_destroy_surface_storage(struct object_surface *obj_surface)
{
- if (!obj_surface)
+ if (!obj_surface || !obj_surface->bo)
return;
dri_bo_unreference(obj_surface->bo);
Xiang, Haihao
2016-12-30 08:26:25 UTC
Permalink
Post by Zhao Yakui
In fact the dri_bo_unreference function can handle the scenario that bo
is NULL.
Yes, it is like as free() with NULL pointer.
Post by Zhao Yakui
Of course it also looks good to me that the explicit check is added in
the i965_destroy_surface_storage.
I think the original code is clean and prefer the original code.
Post by Zhao Yakui
Thanks
---
  src/i965_drv_video.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c
index bf59374..ded3d93 100644
--- a/src/i965_drv_video.c
+++ b/src/i965_drv_video.c
@@ -1210,7 +1210,7 @@ VAStatus
i965_QueryConfigAttributes(VADriverContextP ctx,
  void
  i965_destroy_surface_storage(struct object_surface *obj_surface)
  {
-    if (!obj_surface)
+    if (!obj_surface || !obj_surface->bo)
          return;
      dri_bo_unreference(obj_surface->bo);
_______________________________________________
Libva mailing list
https://lists.freedesktop.org/mailman/listinfo/libva
Chen, Peng C
2016-12-30 08:39:08 UTC
Permalink
Yes, the original one could fix my problem.
I found it is actually called several times for the NULL bo in some application. And this patch will improve the performance a little.

-----Original Message-----
From: Libva [mailto:libva-***@lists.freedesktop.org] On Behalf Of Xiang, Haihao
Sent: Friday, December 30, 2016 4:26 PM
To: Zhao, Yakui <***@intel.com>; ***@lists.freedesktop.org
Subject: Re: [Libva] [PATCH V1][libva-intel-driver] Return if the surface bo is NULL
Post by Zhao Yakui
In fact the dri_bo_unreference function can handle the scenario that
bo is NULL.
Yes, it is like as free() with NULL pointer.
Post by Zhao Yakui
Of course it also looks good to me that the explicit check is added in
the i965_destroy_surface_storage.
I think the original code is clean and prefer the original code.
Post by Zhao Yakui
Thanks
---
  src/i965_drv_video.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c index
bf59374..ded3d93 100644
--- a/src/i965_drv_video.c
+++ b/src/i965_drv_video.c
@@ -1210,7 +1210,7 @@ VAStatus
i965_QueryConfigAttributes(VADriverContextP ctx,
  void
  i965_destroy_surface_storage(struct object_surface *obj_surface)
  {
-    if (!obj_surface)
+    if (!obj_surface || !obj_surface->bo)
          return;
      dri_bo_unreference(obj_surface->bo);
_______________________________________________
Libva mailing list
https://lists.freedesktop.org/mailman/listinfo/libva
_______________________________________________
Libva mailing list
***@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libva

Loading...