mirror of
				git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
				synced 2025-10-31 16:54:21 +00:00 
			
		
		
		
	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>
This commit is contained in:
		
							parent
							
								
									e8f45e3341
								
							
						
					
					
						commit
						e3db9ef6eb
					
				
					 1 changed files with 1 additions and 6 deletions
				
			
		|  | @ -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) | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Julia Lawall
						Julia Lawall