Skip to content

Commit 90962b3

Browse files
Gavrilov Iliagregkh
authored andcommitted
relay: fix type mismatch when allocating memory in relay_create_buf()
[ Upstream commit 4d8586e ] 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: b86ff98 ("[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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 0d60b11 commit 90962b3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/relay.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,13 @@ static struct rchan_buf *relay_create_buf(struct rchan *chan)
151151
{
152152
struct rchan_buf *buf;
153153

154-
if (chan->n_subbufs > KMALLOC_MAX_SIZE / sizeof(size_t *))
154+
if (chan->n_subbufs > KMALLOC_MAX_SIZE / sizeof(size_t))
155155
return NULL;
156156

157157
buf = kzalloc(sizeof(struct rchan_buf), GFP_KERNEL);
158158
if (!buf)
159159
return NULL;
160-
buf->padding = kmalloc_array(chan->n_subbufs, sizeof(size_t *),
160+
buf->padding = kmalloc_array(chan->n_subbufs, sizeof(size_t),
161161
GFP_KERNEL);
162162
if (!buf->padding)
163163
goto free_buf;

0 commit comments

Comments
 (0)