From: Markus Elfring elfring@users.sourceforge.net
Further update suggestions were taken into account after a patch was applied from static source code analysis.
Markus Elfring (2): Delete an unnecessary check before the function call "dsi_destroy" One function call less in dsi_init() after error detection
drivers/gpu/drm/msm/dsi/dsi.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-)
From: Markus Elfring elfring@users.sourceforge.net Date: Sat, 27 Jun 2015 22:05:31 +0200
The dsi_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring elfring@users.sourceforge.net --- drivers/gpu/drm/msm/dsi/dsi.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/msm/dsi/dsi.c b/drivers/gpu/drm/msm/dsi/dsi.c index 1f2561e..dc4f38f 100644 --- a/drivers/gpu/drm/msm/dsi/dsi.c +++ b/drivers/gpu/drm/msm/dsi/dsi.c @@ -110,9 +110,7 @@ static struct msm_dsi *dsi_init(struct platform_device *pdev) return msm_dsi;
fail: - if (msm_dsi) - dsi_destroy(msm_dsi); - + dsi_destroy(msm_dsi); return ERR_PTR(ret); }
From: Markus Elfring elfring@users.sourceforge.net Date: Sat, 27 Jun 2015 22:23:28 +0200
The dsi_destroy() function was called in two cases by the dsi_init() function during error handling even if the passed variable contained a null pointer.
* This implementation detail could be improved by adjustments for jump targets according to the Linux coding style convention.
* Drop an unnecessary initialisation for the variable "msm_dsi" then.
Signed-off-by: Markus Elfring elfring@users.sourceforge.net --- drivers/gpu/drm/msm/dsi/dsi.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/msm/dsi/dsi.c b/drivers/gpu/drm/msm/dsi/dsi.c index dc4f38f..971f000 100644 --- a/drivers/gpu/drm/msm/dsi/dsi.c +++ b/drivers/gpu/drm/msm/dsi/dsi.c @@ -74,19 +74,15 @@ static void dsi_destroy(struct msm_dsi *msm_dsi)
static struct msm_dsi *dsi_init(struct platform_device *pdev) { - struct msm_dsi *msm_dsi = NULL; + struct msm_dsi *msm_dsi; int ret;
- if (!pdev) { - ret = -ENXIO; - goto fail; - } + if (!pdev) + return -ENXIO;
msm_dsi = devm_kzalloc(&pdev->dev, sizeof(*msm_dsi), GFP_KERNEL); - if (!msm_dsi) { - ret = -ENOMEM; - goto fail; - } + if (!msm_dsi) + return -ENOMEM; DBG("dsi probed=%p", msm_dsi);
msm_dsi->pdev = pdev; @@ -95,21 +91,21 @@ static struct msm_dsi *dsi_init(struct platform_device *pdev) /* Init dsi host */ ret = msm_dsi_host_init(msm_dsi); if (ret) - goto fail; + goto destroy_dsi;
/* GET dsi PHY */ ret = dsi_get_phy(msm_dsi); if (ret) - goto fail; + goto destroy_dsi;
/* Register to dsi manager */ ret = msm_dsi_manager_register(msm_dsi); if (ret) - goto fail; + goto destroy_dsi;
return msm_dsi;
-fail: +destroy_dsi: dsi_destroy(msm_dsi); return ERR_PTR(ret); }
dri-devel@lists.freedesktop.org