mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] relay: Fix type mismatch when allocating memory in relay_create_buf()
@ 2022-11-29  9:23 Gavrilov Ilia
  2022-11-29 23:30 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: Gavrilov Ilia @ 2022-11-29  9:23 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Gavrilov Ilia, Colin Ian King, wuchi, Jens Axboe, linux-kernel,
	lvc-project

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.

Fixes: b86ff981a825 ("[PATCH] relay: migrate from relayfs to a generic relay API")
Signed-off-by: Ilia.Gavrilov <Ilia.Gavrilov@infotecs.ru>
---
 kernel/relay.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/relay.c b/kernel/relay.c
index d7edc934c56d..88bcb09f0a1f 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -148,13 +148,13 @@ static struct rchan_buf *relay_create_buf(struct rchan *chan)
 {
 	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;
 
 	buf = kzalloc(sizeof(struct rchan_buf), GFP_KERNEL);
 	if (!buf)
 		return NULL;
-	buf->padding = kmalloc_array(chan->n_subbufs, sizeof(size_t *),
+	buf->padding = kmalloc_array(chan->n_subbufs, sizeof(size_t),
 				     GFP_KERNEL);
 	if (!buf->padding)
 		goto free_buf;
-- 
2.30.2

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-29 23:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-29  9:23 [PATCH] relay: Fix type mismatch when allocating memory in relay_create_buf() Gavrilov Ilia
2022-11-29 23:30 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®