Skip to content

Commit

Permalink
sh: sq: Fix incorrect element size for allocating bitmap buffer
Browse files Browse the repository at this point in the history
[ Upstream commit 80f746e ]

The Store Queue code allocates a bitmap buffer with the size of
multiple of sizeof(long) in sq_api_init(). While the buffer size
is calculated correctly, the code uses the wrong element size to
allocate the buffer which results in the allocated bitmap buffer
being too small.

Fix this by allocating the buffer with kcalloc() with element size
sizeof(long) instead of kzalloc() whose elements size defaults to
sizeof(char).

Fixes: d7c30c6 ("sh: Store Queue API rework.")
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Link: https://lore.kernel.org/r/20230419114854.528677-1-glaubitz@physik.fu-berlin.de
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
glaubitz authored and gregkh committed May 11, 2023
1 parent eb4d2f3 commit 1cee431
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion arch/sh/kernel/cpu/sh4/sq.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ static int __init sq_api_init(void)
if (unlikely(!sq_cache))
return ret;

sq_bitmap = kzalloc(size, GFP_KERNEL);
sq_bitmap = kcalloc(size, sizeof(long), GFP_KERNEL);
if (unlikely(!sq_bitmap))
goto out;

Expand Down

0 comments on commit 1cee431

Please sign in to comment.