Commit 5663077a authored by Colin Ian King's avatar Colin Ian King Committed by Eric Anholt

drm/vc4: clean up error handling on devm_kzalloc failure

The current error handling when devm_kzalloc fails performs a
non-null check on connector which is redundant because connector
is null at that failure point.  Once this is removed, make the
failure path into a trivial -ENOMEM return to clean up the
error handling. Also remove need to initialize connector to NULL.

Detected by CoverityScan CID#1339527 ("Logically dead code")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Signed-off-by: default avatarEric Anholt <eric@anholt.net>
Reviewed-by: default avatarEric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/20170908140504.1340-1-colin.king@canonical.com
parent 45ae2787
...@@ -309,16 +309,13 @@ static const struct drm_connector_helper_funcs vc4_hdmi_connector_helper_funcs = ...@@ -309,16 +309,13 @@ static const struct drm_connector_helper_funcs vc4_hdmi_connector_helper_funcs =
static struct drm_connector *vc4_hdmi_connector_init(struct drm_device *dev, static struct drm_connector *vc4_hdmi_connector_init(struct drm_device *dev,
struct drm_encoder *encoder) struct drm_encoder *encoder)
{ {
struct drm_connector *connector = NULL; struct drm_connector *connector;
struct vc4_hdmi_connector *hdmi_connector; struct vc4_hdmi_connector *hdmi_connector;
int ret = 0;
hdmi_connector = devm_kzalloc(dev->dev, sizeof(*hdmi_connector), hdmi_connector = devm_kzalloc(dev->dev, sizeof(*hdmi_connector),
GFP_KERNEL); GFP_KERNEL);
if (!hdmi_connector) { if (!hdmi_connector)
ret = -ENOMEM; return ERR_PTR(-ENOMEM);
goto fail;
}
connector = &hdmi_connector->base; connector = &hdmi_connector->base;
hdmi_connector->encoder = encoder; hdmi_connector->encoder = encoder;
...@@ -336,12 +333,6 @@ static struct drm_connector *vc4_hdmi_connector_init(struct drm_device *dev, ...@@ -336,12 +333,6 @@ static struct drm_connector *vc4_hdmi_connector_init(struct drm_device *dev,
drm_mode_connector_attach_encoder(connector, encoder); drm_mode_connector_attach_encoder(connector, encoder);
return connector; return connector;
fail:
if (connector)
vc4_hdmi_connector_destroy(connector);
return ERR_PTR(ret);
} }
static void vc4_hdmi_encoder_destroy(struct drm_encoder *encoder) static void vc4_hdmi_encoder_destroy(struct drm_encoder *encoder)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment