mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-19 11:43:40 +00:00
relay: fix type mismatch when allocating memory in relay_create_buf()
The 'padding' field of the 'rchan_buf' structure is an array of 'size_t' elements, but the memory is allocated for an array of 'size_t *' elements. Found by Linux Verification Center (linuxtesting.org) with SVACE. Link: https://lkml.kernel.org/r/20221129092002.3538384-1-Ilia.Gavrilov@infotecs.ru Fixes: b86ff981a825 ("[PATCH] relay: migrate from relayfs to a generic relay API") Signed-off-by: Ilia.Gavrilov <Ilia.Gavrilov@infotecs.ru> Cc: Colin Ian King <colin.i.king@gmail.com> Cc: Jens Axboe <axboe@kernel.dk> Cc: wuchi <wuchi.zero@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
c9a934c7d8
commit
4d8586e046
@ -148,13 +148,13 @@ static struct rchan_buf *relay_create_buf(struct rchan *chan)
|
|||||||
{
|
{
|
||||||
struct rchan_buf *buf;
|
struct rchan_buf *buf;
|
||||||
|
|
||||||
if (chan->n_subbufs > KMALLOC_MAX_SIZE / sizeof(size_t *))
|
if (chan->n_subbufs > KMALLOC_MAX_SIZE / sizeof(size_t))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
buf = kzalloc(sizeof(struct rchan_buf), GFP_KERNEL);
|
buf = kzalloc(sizeof(struct rchan_buf), GFP_KERNEL);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return NULL;
|
return NULL;
|
||||||
buf->padding = kmalloc_array(chan->n_subbufs, sizeof(size_t *),
|
buf->padding = kmalloc_array(chan->n_subbufs, sizeof(size_t),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!buf->padding)
|
if (!buf->padding)
|
||||||
goto free_buf;
|
goto free_buf;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user