forked from mirrors/linux
		
	workqueue: Don't call va_start / va_end twice
Calling va_start / va_end multiple times is undefined and causes problems with certain compiler / platforms. Change alloc_ordered_workqueue_lockdep_map to a macro and updated __alloc_workqueue to take a va_list argument. Cc: Sergey Senozhatsky <senozhatsky@chromium.org> Cc: Tejun Heo <tj@kernel.org> Cc: Lai Jiangshan <jiangshanlai@gmail.com> Signed-off-by: Matthew Brost <matthew.brost@intel.com> Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
		
							parent
							
								
									8dffaec34d
								
							
						
					
					
						commit
						9b59a85a84
					
				
					 2 changed files with 3 additions and 19 deletions
				
			
		|  | @ -543,20 +543,8 @@ alloc_workqueue_lockdep_map(const char *fmt, unsigned int flags, int max_active, | ||||||
|  * RETURNS: |  * RETURNS: | ||||||
|  * Pointer to the allocated workqueue on success, %NULL on failure. |  * Pointer to the allocated workqueue on success, %NULL on failure. | ||||||
|  */ |  */ | ||||||
| __printf(1, 4) static inline struct workqueue_struct * | #define alloc_ordered_workqueue_lockdep_map(fmt, flags, lockdep_map, args...)	\ | ||||||
| alloc_ordered_workqueue_lockdep_map(const char *fmt, unsigned int flags, | 	alloc_workqueue_lockdep_map(fmt, WQ_UNBOUND | __WQ_ORDERED | (flags), 1, lockdep_map, ##args) | ||||||
| 				    struct lockdep_map *lockdep_map, ...) |  | ||||||
| { |  | ||||||
| 	struct workqueue_struct *wq; |  | ||||||
| 	va_list args; |  | ||||||
| 
 |  | ||||||
| 	va_start(args, lockdep_map); |  | ||||||
| 	wq = alloc_workqueue_lockdep_map(fmt, WQ_UNBOUND | __WQ_ORDERED | flags, |  | ||||||
| 					 1, lockdep_map, args); |  | ||||||
| 	va_end(args); |  | ||||||
| 
 |  | ||||||
| 	return wq; |  | ||||||
| } |  | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  |  | ||||||
|  | @ -5619,12 +5619,10 @@ static void wq_adjust_max_active(struct workqueue_struct *wq) | ||||||
| 	} while (activated); | 	} while (activated); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| __printf(1, 4) |  | ||||||
| static struct workqueue_struct *__alloc_workqueue(const char *fmt, | static struct workqueue_struct *__alloc_workqueue(const char *fmt, | ||||||
| 						  unsigned int flags, | 						  unsigned int flags, | ||||||
| 						  int max_active, ...) | 						  int max_active, va_list args) | ||||||
| { | { | ||||||
| 	va_list args; |  | ||||||
| 	struct workqueue_struct *wq; | 	struct workqueue_struct *wq; | ||||||
| 	size_t wq_size; | 	size_t wq_size; | ||||||
| 	int name_len; | 	int name_len; | ||||||
|  | @ -5656,9 +5654,7 @@ static struct workqueue_struct *__alloc_workqueue(const char *fmt, | ||||||
| 			goto err_free_wq; | 			goto err_free_wq; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	va_start(args, max_active); |  | ||||||
| 	name_len = vsnprintf(wq->name, sizeof(wq->name), fmt, args); | 	name_len = vsnprintf(wq->name, sizeof(wq->name), fmt, args); | ||||||
| 	va_end(args); |  | ||||||
| 
 | 
 | ||||||
| 	if (name_len >= WQ_NAME_LEN) | 	if (name_len >= WQ_NAME_LEN) | ||||||
| 		pr_warn_once("workqueue: name exceeds WQ_NAME_LEN. Truncating to: %s\n", | 		pr_warn_once("workqueue: name exceeds WQ_NAME_LEN. Truncating to: %s\n", | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Matthew Brost
						Matthew Brost