dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Philipp Zabel <p.zabel@pengutronix.de>
To: Fabio Estevam <festevam@gmail.com>, airlied@linux.ie
Cc: etnaviv@lists.freedesktop.org, stable@vger.kernel.org,
	linux@armlinux.org.uk, dri-devel@lists.freedesktop.org,
	kernel@pengutronix.de, linux+etnaviv@armlinux.org.uk,
	Fabio Estevam <fabio.estevam@nxp.com>
Subject: Re: [PATCH v3 1/2] drm/etnaviv: Check for platform_device_register_simple() failure
Date: Wed, 27 Jun 2018 14:33:04 +0200	[thread overview]
Message-ID: <1530102784.3419.11.camel@pengutronix.de> (raw)
In-Reply-To: <1529954173-7728-1-git-send-email-festevam@gmail.com>

On Mon, 2018-06-25 at 16:16 -0300, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@nxp.com>
> 
> platform_device_register_simple() may fail, so we should better
> check its return value and propagate it in the case of error.
> 
> Cc: <stable@vger.kernel.org>
> Fixes: 246774d17fc0 ("drm/etnaviv: remove the need for a gpu-subsystem DT node")
> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
> ---
> Changes since v2:
> - Newly introduced in this version
> 
>  drivers/gpu/drm/etnaviv/etnaviv_drv.c | 18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> index e5013a9..ac23c0f 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> @@ -631,6 +631,8 @@ static struct platform_driver etnaviv_platform_driver = {
>  	},
>  };
>  
> +static struct platform_device *etnaviv_drm;
> +
>  static int __init etnaviv_init(void)
>  {
>  	int ret;
> @@ -644,7 +646,7 @@ static int __init etnaviv_init(void)
>  
>  	ret = platform_driver_register(&etnaviv_platform_driver);
>  	if (ret != 0)
> -		platform_driver_unregister(&etnaviv_gpu_driver);
> +		goto unregister_gpu_driver;
>  
>  	/*
>  	 * If the DT contains at least one available GPU device, instantiate
> @@ -653,12 +655,22 @@ static int __init etnaviv_init(void)
>  	for_each_compatible_node(np, NULL, "vivante,gc") {
>  		if (!of_device_is_available(np))
>  			continue;
> -
> -		platform_device_register_simple("etnaviv", -1, NULL, 0);
> +		etnaviv_drm = platform_device_register_simple("etnaviv", -1,
> +							      NULL, 0);

Rather than store the error value in the global variable, I'd use a
local variable here and only set etnaviv_drm if this doesn't fail.

> +		if (IS_ERR(etnaviv_drm)) {
> +			ret = PTR_ERR(etnaviv_drm);
> +			goto unregister_platform_driver;
> +		}
>  		of_node_put(np);
>  		break;

Ah, focusing on etnaviv_exit last time I've completely overlooked this
break.

>  	}
>  
> +	return 0;
> +
> +unregister_platform_driver:
> +	platform_driver_unregister(&etnaviv_platform_driver);
> +unregister_gpu_driver:
> +	platform_driver_unregister(&etnaviv_gpu_driver);
>  	return ret;
>  }
>  module_init(etnaviv_init);
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

      parent reply	other threads:[~2018-06-27 12:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-25 19:16 [PATCH v3 1/2] drm/etnaviv: Check for platform_device_register_simple() failure Fabio Estevam
2018-06-25 19:16 ` [PATCH v3 2/2] drm/etnaviv: Fix driver unregistering Fabio Estevam
2018-06-27 12:33   ` Philipp Zabel
2018-06-27 12:33 ` Philipp Zabel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1530102784.3419.11.camel@pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=etnaviv@lists.freedesktop.org \
    --cc=fabio.estevam@nxp.com \
    --cc=festevam@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux+etnaviv@armlinux.org.uk \
    --cc=linux@armlinux.org.uk \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox