Skip to contentSkip to conversation

drm/xen-front: fix xen_drm_front_shbuf_alloc() error handling

PATCH Applied Dan Carpenter 2 participants 5 messages May 8, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 2/3 drm/xen-front: fix xen_drm_front_shbuf_alloc() error handling

The xen_drm_front_shbuf_alloc() function was returning a mix of error pointers and NULL and the the caller wasn't checking correctly. I've changed it to always return error pointer consistently.

Fixes c575b7eeb89f ("drm/xen-front: Add support for Xen PV display frontend")
drivers/gpu/drm/xen/xen_drm_front_shbuf.c +1 -1
index d5705251a0d6..8099cb343ae3 100644
@@ -383,7 +383,7 @@ xen_drm_front_shbuf_alloc(struct xen_drm_front_shbuf_cfg *cfg)
 
 	buf = kzalloc(sizeof(*buf), GFP_KERNEL);
 	if (!buf)
-		return NULL;
+		return ERR_PTR(-ENOMEM);
 
 	if (cfg->be_alloc)
 		buf->ops = &backend_ops;
drivers/gpu/drm/xen/xen_drm_front.c +2 -2
index 8615e8522c7a..378cb7ce0db5 100644
@@ -188,8 +188,8 @@ int xen_drm_front_dbuf_create(struct xen_drm_front_info *front_info,
 	buf_cfg.be_alloc = front_info->cfg.be_alloc;
 
 	shbuf = xen_drm_front_shbuf_alloc(&buf_cfg);
-	if (!shbuf)
-		return -ENOMEM;
+	if (IS_ERR(shbuf))
+		return PTR_ERR(shbuf);
 
 	ret = dbuf_add_to_list(front_info, shbuf, dbuf_cookie);
 	if (ret < 0) {
Reviewed-by on v1 2/3
#1 lore raw
Quoted 6 lines · Dan Carpenter

The xen_drm_front_shbuf_alloc() function was returning a mix of error pointers and NULL and the the caller wasn't checking correctly. I've changed it to always return error pointer consistently.

Fixes c575b7eeb89f ("drm/xen-front: Add support for Xen PV display frontend")

Thank you,

Quoted 32 lines
drivers/gpu/drm/xen/xen_drm_front_shbuf.c +1 -1
index d5705251a0d6..8099cb343ae3 100644
@@ -383,7 +383,7 @@ xen_drm_front_shbuf_alloc(struct xen_drm_front_shbuf_cfg *cfg)
 
  	buf = kzalloc(sizeof(*buf), GFP_KERNEL);
  	if (!buf)
-		return NULL;
+		return ERR_PTR(-ENOMEM);
 
  	if (cfg->be_alloc)
  		buf->ops = &backend_ops;
drivers/gpu/drm/xen/xen_drm_front.c +2 -2
index 8615e8522c7a..378cb7ce0db5 100644
@@ -188,8 +188,8 @@ int xen_drm_front_dbuf_create(struct xen_drm_front_info *front_info,
  	buf_cfg.be_alloc = front_info->cfg.be_alloc;
 
  	shbuf = xen_drm_front_shbuf_alloc(&buf_cfg);
-	if (!shbuf)
-		return -ENOMEM;
+	if (IS_ERR(shbuf))
+		return PTR_ERR(shbuf);
 
  	ret = dbuf_add_to_list(front_info, shbuf, dbuf_cookie);
  	if (ret < 0) {

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
Quoted 10 lines · Oleksandr Andrushchenko
Quoted 7 lines · Dan Carpenter

The xen_drm_front_shbuf_alloc() function was returning a mix of error pointers and NULL and the the caller wasn't checking correctly. I've changed it to always return error pointer consistently.

Fixes c575b7eeb89f ("drm/xen-front: Add support for Xen PV display

frontend")

Thank you,

Applied to drm-misc-next,
Thank you

Quoted 33 lines
Quoted 32 lines
drivers/gpu/drm/xen/xen_drm_front_shbuf.c +1 -1
index d5705251a0d6..8099cb343ae3 100644
@@ -383,7 +383,7 @@ xen_drm_front_shbuf_alloc(struct 
 xen_drm_front_shbuf_cfg *cfg)
         buf = kzalloc(sizeof(*buf), GFP_KERNEL);
       if (!buf)
-        return NULL;
+        return ERR_PTR(-ENOMEM);
         if (cfg->be_alloc)
           buf->ops = &backend_ops;
drivers/gpu/drm/xen/xen_drm_front.c +2 -2
index 8615e8522c7a..378cb7ce0db5 100644
@@ -188,8 +188,8 @@ int xen_drm_front_dbuf_create(struct 
 xen_drm_front_info *front_info,
       buf_cfg.be_alloc = front_info->cfg.be_alloc;
         shbuf = xen_drm_front_shbuf_alloc(&buf_cfg);
-    if (!shbuf)
-        return -ENOMEM;
+    if (IS_ERR(shbuf))
+        return PTR_ERR(shbuf);
         ret = dbuf_add_to_list(front_info, shbuf, dbuf_cookie);
       if (ret < 0) {

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw
In reply to Oleksandr Andrushchenko
Quoted 9 lines · Oleksandr Andrushchenko
Quoted 6 lines · Dan Carpenter

The xen_drm_front_shbuf_alloc() function was returning a mix of error pointers and NULL and the the caller wasn't checking correctly. I've changed it to always return error pointer consistently.

Fixes c575b7eeb89f ("drm/xen-front: Add support for Xen PV display frontend")

Thank you,

Applied to drm-misc-next,
Thank you

Quoted 22 lines
Quoted 22 lines
drivers/gpu/drm/xen/xen_drm_front_shbuf.c +1 -1
index d5705251a0d6..8099cb343ae3 100644
@@ -383,7 +383,7 @@ xen_drm_front_shbuf_alloc(struct 
 xen_drm_front_shbuf_cfg *cfg)
         buf = kzalloc(sizeof(*buf), GFP_KERNEL);
       if (!buf)
-        return NULL;
+        return ERR_PTR(-ENOMEM);
         if (cfg->be_alloc)
           buf->ops = &backend_ops;
drivers/gpu/drm/xen/xen_drm_front.c +0 -2
index 8615e8522c7a..378cb7ce0db5 100644
@@ -188,8 +188,8 @@ int xen_drm_front_dbuf_create(struct 
 xen_drm_front_info *front_info,
       buf_cfg.be_alloc = front_info->cfg.be_alloc;
         shbuf = xen_drm_front_shbuf_alloc(&buf_cfg);
-    if (!shbuf)
-        return -ENOMEM;
Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/xen/xen_drm_front.c +2 -0
+    if (IS_ERR(shbuf))
+        return PTR_ERR(shbuf);
         ret = dbuf_add_to_list(front_info, shbuf, dbuf_cookie);
       if (ret < 0) {

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reviewed-by on v1 2/3
#4 lore raw
In reply to Dan Carpenter
Quoted 6 lines · Dan Carpenter

The xen_drm_front_shbuf_alloc() function was returning a mix of error pointers and NULL and the the caller wasn't checking correctly. I've changed it to always return error pointer consistently.

Fixes c575b7eeb89f ("drm/xen-front: Add support for Xen PV display frontend")

Thank you,

Quoted 28 lines
drivers/gpu/drm/xen/xen_drm_front_shbuf.c +1 -1
index d5705251a0d6..8099cb343ae3 100644
@@ -383,7 +383,7 @@ xen_drm_front_shbuf_alloc(struct xen_drm_front_shbuf_cfg *cfg)
 
  	buf = kzalloc(sizeof(*buf), GFP_KERNEL);
  	if (!buf)
-		return NULL;
+		return ERR_PTR(-ENOMEM);
 
  	if (cfg->be_alloc)
  		buf->ops = &backend_ops;
drivers/gpu/drm/xen/xen_drm_front.c +2 -2
index 8615e8522c7a..378cb7ce0db5 100644
@@ -188,8 +188,8 @@ int xen_drm_front_dbuf_create(struct xen_drm_front_info *front_info,
  	buf_cfg.be_alloc = front_info->cfg.be_alloc;
 
  	shbuf = xen_drm_front_shbuf_alloc(&buf_cfg);
-	if (!shbuf)
-		return -ENOMEM;
+	if (IS_ERR(shbuf))
+		return PTR_ERR(shbuf);
 
  	ret = dbuf_add_to_list(front_info, shbuf, dbuf_cookie);
  	if (ret < 0) {
Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel