Skip to content

Commit 9b59a85

Browse files
mbrost05htejun
authored andcommitted
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 <[email protected]> Cc: Tejun Heo <[email protected]> Cc: Lai Jiangshan <[email protected]> Signed-off-by: Matthew Brost <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 8dffaec commit 9b59a85

File tree

2 files changed

+3
-19
lines changed

2 files changed

+3
-19
lines changed

include/linux/workqueue.h

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -543,20 +543,8 @@ alloc_workqueue_lockdep_map(const char *fmt, unsigned int flags, int max_active,
543543
* RETURNS:
544544
* Pointer to the allocated workqueue on success, %NULL on failure.
545545
*/
546-
__printf(1, 4) static inline struct workqueue_struct *
547-
alloc_ordered_workqueue_lockdep_map(const char *fmt, unsigned int flags,
548-
struct lockdep_map *lockdep_map, ...)
549-
{
550-
struct workqueue_struct *wq;
551-
va_list args;
552-
553-
va_start(args, lockdep_map);
554-
wq = alloc_workqueue_lockdep_map(fmt, WQ_UNBOUND | __WQ_ORDERED | flags,
555-
1, lockdep_map, args);
556-
va_end(args);
557-
558-
return wq;
559-
}
546+
#define alloc_ordered_workqueue_lockdep_map(fmt, flags, lockdep_map, args...) \
547+
alloc_workqueue_lockdep_map(fmt, WQ_UNBOUND | __WQ_ORDERED | (flags), 1, lockdep_map, ##args)
560548
#endif
561549

562550
/**

kernel/workqueue.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5619,12 +5619,10 @@ static void wq_adjust_max_active(struct workqueue_struct *wq)
56195619
} while (activated);
56205620
}
56215621

5622-
__printf(1, 4)
56235622
static struct workqueue_struct *__alloc_workqueue(const char *fmt,
56245623
unsigned int flags,
5625-
int max_active, ...)
5624+
int max_active, va_list args)
56265625
{
5627-
va_list args;
56285626
struct workqueue_struct *wq;
56295627
size_t wq_size;
56305628
int name_len;
@@ -5656,9 +5654,7 @@ static struct workqueue_struct *__alloc_workqueue(const char *fmt,
56565654
goto err_free_wq;
56575655
}
56585656

5659-
va_start(args, max_active);
56605657
name_len = vsnprintf(wq->name, sizeof(wq->name), fmt, args);
5661-
va_end(args);
56625658

56635659
if (name_len >= WQ_NAME_LEN)
56645660
pr_warn_once("workqueue: name exceeds WQ_NAME_LEN. Truncating to: %s\n",

0 commit comments

Comments
 (0)