Skip to content

Commit 85c4f6b

Browse files
author
Robert Foss
committed
workqueue: Don't call va_start / va_end twice
JIRA: https://issues.redhat.com/browse/RHEL-53569 Upstream Status: v6.12-rc1 commit 9b59a85 Author: Matthew Brost <matthew.brost@intel.com> AuthorDate: Tue Aug 20 12:38:08 2024 -0700 Commit: Tejun Heo <tj@kernel.org> CommitDate: Tue Aug 20 09:38:39 2024 -1000 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> Signed-off-by: Robert Foss <rfoss@redhat.com>
1 parent e29258c commit 85c4f6b

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
@@ -536,20 +536,8 @@ alloc_workqueue_lockdep_map(const char *fmt, unsigned int flags, int max_active,
536536
* RETURNS:
537537
* Pointer to the allocated workqueue on success, %NULL on failure.
538538
*/
539-
__printf(1, 4) static inline struct workqueue_struct *
540-
alloc_ordered_workqueue_lockdep_map(const char *fmt, unsigned int flags,
541-
struct lockdep_map *lockdep_map, ...)
542-
{
543-
struct workqueue_struct *wq;
544-
va_list args;
545-
546-
va_start(args, lockdep_map);
547-
wq = alloc_workqueue_lockdep_map(fmt, WQ_UNBOUND | __WQ_ORDERED | flags,
548-
1, lockdep_map, args);
549-
va_end(args);
550-
551-
return wq;
552-
}
539+
#define alloc_ordered_workqueue_lockdep_map(fmt, flags, lockdep_map, args...) \
540+
alloc_workqueue_lockdep_map(fmt, WQ_UNBOUND | __WQ_ORDERED | (flags), 1, lockdep_map, ##args)
553541
#endif
554542

555543
/**

kernel/workqueue.c

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

5540-
__printf(1, 4)
55415540
static struct workqueue_struct *__alloc_workqueue(const char *fmt,
55425541
unsigned int flags,
5543-
int max_active, ...)
5542+
int max_active, va_list args)
55445543
{
5545-
va_list args;
55465544
struct workqueue_struct *wq;
55475545
size_t wq_size;
55485546
int name_len;
@@ -5574,9 +5572,7 @@ static struct workqueue_struct *__alloc_workqueue(const char *fmt,
55745572
goto err_free_wq;
55755573
}
55765574

5577-
va_start(args, max_active);
55785575
name_len = vsnprintf(wq->name, sizeof(wq->name), fmt, args);
5579-
va_end(args);
55805576

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

0 commit comments

Comments
 (0)