dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/vc4: simplify exit path of a failed allocation of dsi_connector
@ 2017-02-03 19:56 Colin King
  2017-02-06 11:48 ` Gustavo Padovan
  2017-02-07 23:46 ` Eric Anholt
  0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2017-02-03 19:56 UTC (permalink / raw)
  To: Eric Anholt, David Airlie, dri-devel; +Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

If dsi_connector fails to allocate, the exit path via label 'fail'
checks if connector is null, which it always is, so the cleanup
that destroys connector is never going to be called.  Hence the
failure path can be more optimally performed by removing this
and just returning ERR_PTR(-ENOMEM).  This also removes the need
to initialize connector to NULL, and we can also remove ret too.

Detected by CoverityScan, CID#1399504 ("Logicall Dead Code")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/gpu/drm/vc4/vc4_dsi.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c
index 2736b03..e328cb86 100644
--- a/drivers/gpu/drm/vc4/vc4_dsi.c
+++ b/drivers/gpu/drm/vc4/vc4_dsi.c
@@ -771,16 +771,14 @@ static const struct drm_connector_helper_funcs vc4_dsi_connector_helper_funcs =
 static struct drm_connector *vc4_dsi_connector_init(struct drm_device *dev,
 						    struct vc4_dsi *dsi)
 {
-	struct drm_connector *connector = NULL;
+	struct drm_connector *connector;
 	struct vc4_dsi_connector *dsi_connector;
-	int ret = 0;
 
 	dsi_connector = devm_kzalloc(dev->dev, sizeof(*dsi_connector),
 				     GFP_KERNEL);
-	if (!dsi_connector) {
-		ret = -ENOMEM;
-		goto fail;
-	}
+	if (!dsi_connector)
+		return ERR_PTR(-ENOMEM);
+
 	connector = &dsi_connector->base;
 
 	dsi_connector->dsi = dsi;
@@ -796,12 +794,6 @@ static struct drm_connector *vc4_dsi_connector_init(struct drm_device *dev,
 	drm_mode_connector_attach_encoder(connector, dsi->encoder);
 
 	return connector;
-
-fail:
-	if (connector)
-		vc4_dsi_connector_destroy(connector);
-
-	return ERR_PTR(ret);
 }
 
 static void vc4_dsi_encoder_destroy(struct drm_encoder *encoder)
-- 
2.10.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm/vc4: simplify exit path of a failed allocation of dsi_connector
  2017-02-03 19:56 [PATCH] drm/vc4: simplify exit path of a failed allocation of dsi_connector Colin King
@ 2017-02-06 11:48 ` Gustavo Padovan
  2017-02-07 23:46 ` Eric Anholt
  1 sibling, 0 replies; 3+ messages in thread
From: Gustavo Padovan @ 2017-02-06 11:48 UTC (permalink / raw)
  To: Colin King; +Cc: kernel-janitors, linux-kernel, dri-devel

Hi Colin,

2017-02-03 Colin King <colin.king@canonical.com>:

> From: Colin Ian King <colin.king@canonical.com>
> 
> If dsi_connector fails to allocate, the exit path via label 'fail'
> checks if connector is null, which it always is, so the cleanup
> that destroys connector is never going to be called.  Hence the
> failure path can be more optimally performed by removing this
> and just returning ERR_PTR(-ENOMEM).  This also removes the need
> to initialize connector to NULL, and we can also remove ret too.
> 
> Detected by CoverityScan, CID#1399504 ("Logicall Dead Code")
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/gpu/drm/vc4/vc4_dsi.c | 16 ++++------------
>  1 file changed, 4 insertions(+), 12 deletions(-)

Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.com>

Gustavo

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm/vc4: simplify exit path of a failed allocation of dsi_connector
  2017-02-03 19:56 [PATCH] drm/vc4: simplify exit path of a failed allocation of dsi_connector Colin King
  2017-02-06 11:48 ` Gustavo Padovan
@ 2017-02-07 23:46 ` Eric Anholt
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Anholt @ 2017-02-07 23:46 UTC (permalink / raw)
  To: Colin King, David Airlie, dri-devel; +Cc: kernel-janitors, linux-kernel


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

Colin King <colin.king@canonical.com> writes:

> From: Colin Ian King <colin.king@canonical.com>
>
> If dsi_connector fails to allocate, the exit path via label 'fail'
> checks if connector is null, which it always is, so the cleanup
> that destroys connector is never going to be called.  Hence the
> failure path can be more optimally performed by removing this
> and just returning ERR_PTR(-ENOMEM).  This also removes the need
> to initialize connector to NULL, and we can also remove ret too.
>
> Detected by CoverityScan, CID#1399504 ("Logicall Dead Code")
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Reviewed and pushed to drm-misc-next.  Thanks!

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

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

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2017-02-07 23:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-03 19:56 [PATCH] drm/vc4: simplify exit path of a failed allocation of dsi_connector Colin King
2017-02-06 11:48 ` Gustavo Padovan
2017-02-07 23:46 ` Eric Anholt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).