From: Jonathan Cameron <jic23@kernel.org>
To: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: Jonathan Cameron <jic23@cam.ac.uk>,
kernel-janitors@vger.kernel.org, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 5/5] drivers/iio/industrialio-event.c: eliminate possible double free
Date: Fri, 02 Nov 2012 09:39:11 +0000 [thread overview]
Message-ID: <509394BF.9020006@kernel.org> (raw)
In-Reply-To: <1350816727-1381-6-git-send-email-Julia.Lawall@lip6.fr>
On 10/21/2012 11:52 AM, Julia Lawall wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
>
> The function __iio_add_event_config_attrs is only called once, by the
> function iio_device_register_eventset. If the call fails,
> iio_device_register_eventset calls __iio_remove_event_config_attrs. There
> is thus no need for __iio_add_event_config_attrs to also call
> __iio_remove_event_config_attrs on failure.
>
> A simplified version of the semantic match that finds this problem is as
> follows: (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @r@
> identifier f,free,a;
> parameter list[n] ps;
> type T;
> expression e;
> @@
>
> f(ps,T a,...) {
> ... when any
> when != a = e
> if(...) { ... free(a); ... return ...; }
> ... when any
> }
>
> @@
> identifier r.f,r.free;
> expression x,a;
> expression list[r.n] xs;
> @@
>
> * x = f(xs,a,...);
> if (...) { ... free(a); ... return ...; }
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Thanks - merged to fixes-togreg branch of iio.git
Jonathan
>
> ---
> __iio_remove_event_config_attrs kfrees the elements of a list, but doesn't
> actually remove them from the list. Perhaps for safety this should be
> cleaned up as well. Not tested.
>
> drivers/iio/industrialio-event.c | 7 +------
> 1 file changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c
> index fa6543b..78570c7 100644
> --- a/drivers/iio/industrialio-event.c
> +++ b/drivers/iio/industrialio-event.c
> @@ -350,15 +350,10 @@ static inline int __iio_add_event_config_attrs(struct iio_dev *indio_dev)
> ret = iio_device_add_event_sysfs(indio_dev,
> &indio_dev->channels[j]);
> if (ret < 0)
> - goto error_clear_attrs;
> + return ret;
> attrcount += ret;
> }
> return attrcount;
> -
> -error_clear_attrs:
> - __iio_remove_event_config_attrs(indio_dev);
> -
> - return ret;
> }
>
> static bool iio_check_for_dynamic_events(struct iio_dev *indio_dev)
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
prev parent reply other threads:[~2012-11-02 9:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1350816727-1381-1-git-send-email-Julia.Lawall@lip6.fr>
2012-10-21 10:52 ` [PATCH 5/5] drivers/iio/industrialio-event.c: eliminate possible double free Julia Lawall
2012-11-02 9:39 ` Jonathan Cameron [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=509394BF.9020006@kernel.org \
--to=jic23@kernel.org \
--cc=Julia.Lawall@lip6.fr \
--cc=jic23@cam.ac.uk \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-iio@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).