Skip to content

Commit 24cc57d

Browse files
ti-kamleshherbertx
authored andcommitted
padata: Honor the caller's alignment in case of chunk_size 0
In the case where we are forcing the ps.chunk_size to be at least 1, we are ignoring the caller's alignment. Move the forcing of ps.chunk_size to be at least 1 before rounding it up to caller's alignment, so that caller's alignment is honored. While at it, use max() to force the ps.chunk_size to be at least 1 to improve readability. Fixes: 6d45e1c ("padata: Fix possible divide-by-0 panic in padata_mt_helper()") Signed-off-by: Kamlesh Gurudasani <kamlesh@ti.com> Acked-by:  Waiman Long <longman@redhat.com> Acked-by: Daniel Jordan <daniel.m.jordan@oracle.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent c7de6ee commit 24cc57d

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

kernel/padata.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,9 +513,12 @@ void __init padata_do_multithreaded(struct padata_mt_job *job)
513513
* thread function. Load balance large jobs between threads by
514514
* increasing the number of chunks, guarantee at least the minimum
515515
* chunk size from the caller, and honor the caller's alignment.
516+
* Ensure chunk_size is at least 1 to prevent divide-by-0
517+
* panic in padata_mt_helper().
516518
*/
517519
ps.chunk_size = job->size / (ps.nworks * load_balance_factor);
518520
ps.chunk_size = max(ps.chunk_size, job->min_chunk);
521+
ps.chunk_size = max(ps.chunk_size, 1ul);
519522
ps.chunk_size = roundup(ps.chunk_size, job->align);
520523

521524
list_for_each_entry(pw, &works, pw_list)

0 commit comments

Comments
 (0)