2018-02-07 21:46:18

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 0/2] drm/msm/mdp4: Adjustments for mdp4_kms_init()

From: Markus Elfring <[email protected]>
Date: Wed, 7 Feb 2018 22:38:44 +0100

Two update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
Delete an error message for a failed memory allocation
Return directly after a failed kzalloc()

drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)

--
2.16.1



2018-02-07 21:47:56

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 1/2] drm/msm/mdp4: Delete an error message for a failed memory allocation in mdp4_kms_init()

From: Markus Elfring <[email protected]>
Date: Wed, 7 Feb 2018 22:22:28 +0100

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <[email protected]>
---
drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
index f7f087419ed8..5c5965a9d1f9 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
@@ -417,7 +417,6 @@ struct msm_kms *mdp4_kms_init(struct drm_device *dev)

mdp4_kms = kzalloc(sizeof(*mdp4_kms), GFP_KERNEL);
if (!mdp4_kms) {
- dev_err(dev->dev, "failed to allocate kms\n");
ret = -ENOMEM;
goto fail;
}
--
2.16.1


2018-02-07 21:49:13

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 2/2] drm/msm/mdp4: Return directly after a failed kzalloc() in mdp4_kms_init()

From: Markus Elfring <[email protected]>
Date: Wed, 7 Feb 2018 22:34:45 +0100

* Return directly after a call of the function "kzalloc" failed
at the beginning.

* Delete an initialisation and a check (for the local variable "kms")
which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <[email protected]>
---
drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
index 5c5965a9d1f9..4f15cd569ee1 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
@@ -411,15 +411,13 @@ struct msm_kms *mdp4_kms_init(struct drm_device *dev)
struct platform_device *pdev = to_platform_device(dev->dev);
struct mdp4_platform_config *config = mdp4_get_config(pdev);
struct mdp4_kms *mdp4_kms;
- struct msm_kms *kms = NULL;
+ struct msm_kms *kms;
struct msm_gem_address_space *aspace;
int irq, ret;

mdp4_kms = kzalloc(sizeof(*mdp4_kms), GFP_KERNEL);
- if (!mdp4_kms) {
- ret = -ENOMEM;
- goto fail;
- }
+ if (!mdp4_kms)
+ return ERR_PTR(-ENOMEM);

mdp_kms_init(&mdp4_kms->base, &kms_funcs);

@@ -550,8 +548,7 @@ struct msm_kms *mdp4_kms_init(struct drm_device *dev)
return kms;

fail:
- if (kms)
- mdp4_destroy(kms);
+ mdp4_destroy(kms);
return ERR_PTR(ret);
}

--
2.16.1