diff options
author | Julia Lawall <Julia.Lawall@lip6.fr> | 2012-10-21 06:52:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2012-11-17 05:17:20 -0500 |
commit | e3db9ef6eb39ac6d969787bc15756778c2c5ca66 (patch) | |
tree | a7252ad7c63ba80a924983bad6b3fd3be3fe6c84 /drivers/iio | |
parent | e8f45e3341ed8609174f9c21fb47e202f29ab039 (diff) |
drivers/iio/industrialio-event.c: eliminate possible double free
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>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/industrialio-event.c | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c index 857e6306c5c3..261cae00557e 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) | |||
350 | ret = iio_device_add_event_sysfs(indio_dev, | 350 | ret = iio_device_add_event_sysfs(indio_dev, |
351 | &indio_dev->channels[j]); | 351 | &indio_dev->channels[j]); |
352 | if (ret < 0) | 352 | if (ret < 0) |
353 | goto error_clear_attrs; | 353 | return ret; |
354 | attrcount += ret; | 354 | attrcount += ret; |
355 | } | 355 | } |
356 | return attrcount; | 356 | return attrcount; |
357 | |||
358 | error_clear_attrs: | ||
359 | __iio_remove_event_config_attrs(indio_dev); | ||
360 | |||
361 | return ret; | ||
362 | } | 357 | } |
363 | 358 | ||
364 | static bool iio_check_for_dynamic_events(struct iio_dev *indio_dev) | 359 | static bool iio_check_for_dynamic_events(struct iio_dev *indio_dev) |