From: Daniel Vetter <daniel@ffwll.ch>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: airlied@linux.ie, kernel-janitors@vger.kernel.org,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm: Release resources with a safer function
Date: Wed, 05 Oct 2016 13:17:50 +0000 [thread overview]
Message-ID: <20161005131750.GC20761@phenom.ffwll.local> (raw)
In-Reply-To: <1475388082-12656-1-git-send-email-christophe.jaillet@wanadoo.fr>
On Sun, Oct 02, 2016 at 08:01:22AM +0200, Christophe JAILLET wrote:
> We should use 'ida_simple_remove()' instead of 'ida_remove()' when freeing
> resources allocated with 'ida_simple_get()'.
>
> This as been spotted with the following coccinelle script which tries to
> detect missing 'ida_simple_remove()' call in error handling paths.
>
> ///////////////
> @@
> expression x;
> identifier l;
> @@
>
> * x = ida_simple_get(...);
> ...
> if (...) {
> ...
> }
> ...
> if (...) {
> ...
> goto l;
> }
> ...
> * l: ... when != ida_simple_remove(...);
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
kerneldoc for ida_simple_get/remove is rather sparse, would be great to
improve that a bit. Merged this one to drm-misc now, follow-up patch for
the place Ville spotted would be great too.
-Daniel
> ---
> drivers/gpu/drm/drm_connector.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> index 26bb78c76481..2e7430283043 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -250,10 +250,10 @@ int drm_connector_init(struct drm_device *dev,
> connector->debugfs_entry = NULL;
> out_put_type_id:
> if (ret)
> - ida_remove(connector_ida, connector->connector_type_id);
> + ida_simple_remove(connector_ida, connector->connector_type_id);
> out_put_id:
> if (ret)
> - ida_remove(&config->connector_ida, connector->index);
> + ida_simple_remove(&config->connector_ida, connector->index);
> out_put:
> if (ret)
> drm_mode_object_unregister(dev, &connector->base);
> --
> 2.7.4
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
WARNING: multiple messages have this Message-ID (diff)
From: Daniel Vetter <daniel@ffwll.ch>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: airlied@linux.ie, kernel-janitors@vger.kernel.org,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm: Release resources with a safer function
Date: Wed, 5 Oct 2016 15:17:50 +0200 [thread overview]
Message-ID: <20161005131750.GC20761@phenom.ffwll.local> (raw)
In-Reply-To: <1475388082-12656-1-git-send-email-christophe.jaillet@wanadoo.fr>
On Sun, Oct 02, 2016 at 08:01:22AM +0200, Christophe JAILLET wrote:
> We should use 'ida_simple_remove()' instead of 'ida_remove()' when freeing
> resources allocated with 'ida_simple_get()'.
>
> This as been spotted with the following coccinelle script which tries to
> detect missing 'ida_simple_remove()' call in error handling paths.
>
> ///////////////
> @@
> expression x;
> identifier l;
> @@
>
> * x = ida_simple_get(...);
> ...
> if (...) {
> ...
> }
> ...
> if (...) {
> ...
> goto l;
> }
> ...
> * l: ... when != ida_simple_remove(...);
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
kerneldoc for ida_simple_get/remove is rather sparse, would be great to
improve that a bit. Merged this one to drm-misc now, follow-up patch for
the place Ville spotted would be great too.
-Daniel
> ---
> drivers/gpu/drm/drm_connector.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> index 26bb78c76481..2e7430283043 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -250,10 +250,10 @@ int drm_connector_init(struct drm_device *dev,
> connector->debugfs_entry = NULL;
> out_put_type_id:
> if (ret)
> - ida_remove(connector_ida, connector->connector_type_id);
> + ida_simple_remove(connector_ida, connector->connector_type_id);
> out_put_id:
> if (ret)
> - ida_remove(&config->connector_ida, connector->index);
> + ida_simple_remove(&config->connector_ida, connector->index);
> out_put:
> if (ret)
> drm_mode_object_unregister(dev, &connector->base);
> --
> 2.7.4
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
next prev parent reply other threads:[~2016-10-05 13:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-02 6:01 [PATCH] drm: Release resources with a safer function Christophe JAILLET
2016-10-02 6:01 ` Christophe JAILLET
2016-10-03 7:18 ` Ville Syrjälä
2016-10-03 7:18 ` Ville Syrjälä
2016-10-05 13:17 ` Daniel Vetter [this message]
2016-10-05 13:17 ` Daniel Vetter
2016-10-07 7:27 ` Christophe JAILLET
2016-10-07 7:27 ` Christophe JAILLET
2016-10-10 9:22 ` Daniel Vetter
2016-10-10 9:22 ` Daniel Vetter
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=20161005131750.GC20761@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=airlied@linux.ie \
--cc=christophe.jaillet@wanadoo.fr \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.