Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1728807 > unrolled thread
| Started by | Colin King <colin.king@canonical.com> |
|---|---|
| First post | 2017-09-08 15:20 +0200 |
| Last post | 2017-09-08 20:10 +0200 |
| Articles | 4 — 4 participants |
Back to article view | Back to linux.kernel
[PATCH] drm/vc4: clean up error handling on devm_kzalloc failure Colin King <colin.king@canonical.com> - 2017-09-08 15:20 +0200
Re: [PATCH] drm/vc4: clean up error handling on devm_kzalloc failure Emil Velikov <emil.l.velikov@gmail.com> - 2017-09-08 15:50 +0200
Re: [PATCH] drm/vc4: clean up error handling on devm_kzalloc failure Eric Engestrom <eric.engestrom@imgtec.com> - 2017-09-08 16:30 +0200
Re: [PATCH] drm/vc4: clean up error handling on devm_kzalloc failure Eric Anholt <eric@anholt.net> - 2017-09-08 20:10 +0200
| From | Colin King <colin.king@canonical.com> |
|---|---|
| Date | 2017-09-08 15:20 +0200 |
| Subject | [PATCH] drm/vc4: clean up error handling on devm_kzalloc failure |
| Message-ID | <unrmp-7tU-1@gated-at.bofh.it> |
From: Colin Ian King <colin.king@canonical.com>
The current error handling on devm_kzalloc failures performs a non-null
check on connector. Thss check is redundant because connector is null
at that failure point. With this check removed, we may as well make
the failure path into a trivial -ENOMEM return to clean up the error
handling.
Detected by CoverityScan CID#1339527 ("Logically dead code")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/gpu/drm/vc4/vc4_hdmi.c | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
index 937da8dd65b8..a8808c1a1e03 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -311,14 +311,11 @@ static struct drm_connector *vc4_hdmi_connector_init(struct drm_device *dev,
{
struct drm_connector *connector = NULL;
struct vc4_hdmi_connector *hdmi_connector;
- int ret = 0;
hdmi_connector = devm_kzalloc(dev->dev, sizeof(*hdmi_connector),
GFP_KERNEL);
- if (!hdmi_connector) {
- ret = -ENOMEM;
- goto fail;
- }
+ if (!hdmi_connector)
+ return ERR_PTR(-ENOMEM);
connector = &hdmi_connector->base;
hdmi_connector->encoder = encoder;
@@ -336,12 +333,6 @@ static struct drm_connector *vc4_hdmi_connector_init(struct drm_device *dev,
drm_mode_connector_attach_encoder(connector, encoder);
return connector;
-
- fail:
- if (connector)
- vc4_hdmi_connector_destroy(connector);
-
- return ERR_PTR(ret);
}
static void vc4_hdmi_encoder_destroy(struct drm_encoder *encoder)
--
2.14.1
[toc] | [next] | [standalone]
| From | Emil Velikov <emil.l.velikov@gmail.com> |
|---|---|
| Date | 2017-09-08 15:50 +0200 |
| Message-ID | <unrPu-7GO-73@gated-at.bofh.it> |
| In reply to | #1728807 |
Hi Colin,
On 8 September 2017 at 14:17, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The current error handling on devm_kzalloc failures performs a non-null
> check on connector. Thss check is redundant because connector is null
> at that failure point. With this check removed, we may as well make
> the failure path into a trivial -ENOMEM return to clean up the error
> handling.
>
> Detected by CoverityScan CID#1339527 ("Logically dead code")
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/gpu/drm/vc4/vc4_hdmi.c | 13 ++-----------
> 1 file changed, 2 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
> index 937da8dd65b8..a8808c1a1e03 100644
> --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
> +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
> @@ -311,14 +311,11 @@ static struct drm_connector *vc4_hdmi_connector_init(struct drm_device *dev,
> {
> struct drm_connector *connector = NULL;
I think you can drop the initializer now.
-Emil
[toc] | [prev] | [next] | [standalone]
| From | Eric Engestrom <eric.engestrom@imgtec.com> |
|---|---|
| Date | 2017-09-08 16:30 +0200 |
| Message-ID | <unssa-8fk-11@gated-at.bofh.it> |
| In reply to | #1728807 |
On Friday, 2017-09-08 14:17:04 +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The current error handling on devm_kzalloc failures performs a non-null
> check on connector. Thss check is redundant because connector is null
> at that failure point. With this check removed, we may as well make
> the failure path into a trivial -ENOMEM return to clean up the error
> handling.
>
> Detected by CoverityScan CID#1339527 ("Logically dead code")
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/gpu/drm/vc4/vc4_hdmi.c | 13 ++-----------
> 1 file changed, 2 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
> index 937da8dd65b8..a8808c1a1e03 100644
> --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
> +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
> @@ -311,14 +311,11 @@ static struct drm_connector *vc4_hdmi_connector_init(struct drm_device *dev,
> {
> struct drm_connector *connector = NULL;
This `= NULL` isn't needed anymore either.
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
> struct vc4_hdmi_connector *hdmi_connector;
> - int ret = 0;
>
> hdmi_connector = devm_kzalloc(dev->dev, sizeof(*hdmi_connector),
> GFP_KERNEL);
> - if (!hdmi_connector) {
> - ret = -ENOMEM;
> - goto fail;
> - }
> + if (!hdmi_connector)
> + return ERR_PTR(-ENOMEM);
> connector = &hdmi_connector->base;
>
> hdmi_connector->encoder = encoder;
> @@ -336,12 +333,6 @@ static struct drm_connector *vc4_hdmi_connector_init(struct drm_device *dev,
> drm_mode_connector_attach_encoder(connector, encoder);
>
> return connector;
> -
> - fail:
> - if (connector)
> - vc4_hdmi_connector_destroy(connector);
> -
> - return ERR_PTR(ret);
> }
>
> static void vc4_hdmi_encoder_destroy(struct drm_encoder *encoder)
> --
> 2.14.1
>
[toc] | [prev] | [next] | [standalone]
| From | Eric Anholt <eric@anholt.net> |
|---|---|
| Date | 2017-09-08 20:10 +0200 |
| Message-ID | <unvT5-24G-29@gated-at.bofh.it> |
| In reply to | #1728807 |
[Multipart message — attachments visible in raw view] — view raw
Colin King <colin.king@canonical.com> writes:
> From: Colin Ian King <colin.king@canonical.com>
>
> The current error handling on devm_kzalloc failures performs a non-null
> check on connector. Thss check is redundant because connector is null
> at that failure point. With this check removed, we may as well make
> the failure path into a trivial -ENOMEM return to clean up the error
> handling.
>
> Detected by CoverityScan CID#1339527 ("Logically dead code")
Reviewed and applied. Thanks!
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web