8976e2a36d0a0f23b4fe9fa0d3d0fcc16be34efe
[oweals/openwrt.git] /
1 From 628487eea01248eb722b46636a4b0fe45caaf24f Mon Sep 17 00:00:00 2001
2 From: Colin Ian King <colin.king@canonical.com>
3 Date: Fri, 8 Sep 2017 15:05:04 +0100
4 Subject: [PATCH 173/454] drm/vc4: clean up error handling on devm_kzalloc
5  failure
6
7 The current error handling when devm_kzalloc fails performs a
8 non-null check on connector which is redundant because connector
9 is null at that failure point.  Once this is removed, make the
10 failure path into a trivial -ENOMEM return to clean up the
11 error handling. Also remove need to initialize connector to NULL.
12
13 Detected by CoverityScan CID#1339527 ("Logically dead code")
14 Signed-off-by: Colin Ian King <colin.king@canonical.com>
15 Signed-off-by: Eric Anholt <eric@anholt.net>
16 Reviewed-by: Eric Anholt <eric@anholt.net>
17 Link: https://patchwork.freedesktop.org/patch/msgid/20170908140504.1340-1-colin.king@canonical.com
18 (cherry picked from commit 5663077a56804890506c913b3ca9fee78764f8b3)
19 ---
20  drivers/gpu/drm/vc4/vc4_hdmi.c | 15 +++------------
21  1 file changed, 3 insertions(+), 12 deletions(-)
22
23 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
24 +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
25 @@ -309,16 +309,13 @@ static const struct drm_connector_helper
26  static struct drm_connector *vc4_hdmi_connector_init(struct drm_device *dev,
27                                                      struct drm_encoder *encoder)
28  {
29 -       struct drm_connector *connector = NULL;
30 +       struct drm_connector *connector;
31         struct vc4_hdmi_connector *hdmi_connector;
32 -       int ret = 0;
33  
34         hdmi_connector = devm_kzalloc(dev->dev, sizeof(*hdmi_connector),
35                                       GFP_KERNEL);
36 -       if (!hdmi_connector) {
37 -               ret = -ENOMEM;
38 -               goto fail;
39 -       }
40 +       if (!hdmi_connector)
41 +               return ERR_PTR(-ENOMEM);
42         connector = &hdmi_connector->base;
43  
44         hdmi_connector->encoder = encoder;
45 @@ -336,12 +333,6 @@ static struct drm_connector *vc4_hdmi_co
46         drm_mode_connector_attach_encoder(connector, encoder);
47  
48         return connector;
49 -
50 - fail:
51 -       if (connector)
52 -               vc4_hdmi_connector_destroy(connector);
53 -
54 -       return ERR_PTR(ret);
55  }
56  
57  static void vc4_hdmi_encoder_destroy(struct drm_encoder *encoder)