diff options
Diffstat (limited to 'kernel/relay.c')
-rw-r--r-- | kernel/relay.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/kernel/relay.c b/kernel/relay.c index 4335e1d7ee2d..ab56a1764d4d 100644 --- a/kernel/relay.c +++ b/kernel/relay.c | |||
@@ -164,10 +164,14 @@ depopulate: | |||
164 | */ | 164 | */ |
165 | static struct rchan_buf *relay_create_buf(struct rchan *chan) | 165 | static struct rchan_buf *relay_create_buf(struct rchan *chan) |
166 | { | 166 | { |
167 | struct rchan_buf *buf = kzalloc(sizeof(struct rchan_buf), GFP_KERNEL); | 167 | struct rchan_buf *buf; |
168 | if (!buf) | 168 | |
169 | if (chan->n_subbufs > UINT_MAX / sizeof(size_t *)) | ||
169 | return NULL; | 170 | return NULL; |
170 | 171 | ||
172 | buf = kzalloc(sizeof(struct rchan_buf), GFP_KERNEL); | ||
173 | if (!buf) | ||
174 | return NULL; | ||
171 | buf->padding = kmalloc(chan->n_subbufs * sizeof(size_t *), GFP_KERNEL); | 175 | buf->padding = kmalloc(chan->n_subbufs * sizeof(size_t *), GFP_KERNEL); |
172 | if (!buf->padding) | 176 | if (!buf->padding) |
173 | goto free_buf; | 177 | goto free_buf; |
@@ -574,6 +578,8 @@ struct rchan *relay_open(const char *base_filename, | |||
574 | 578 | ||
575 | if (!(subbuf_size && n_subbufs)) | 579 | if (!(subbuf_size && n_subbufs)) |
576 | return NULL; | 580 | return NULL; |
581 | if (subbuf_size > UINT_MAX / n_subbufs) | ||
582 | return NULL; | ||
577 | 583 | ||
578 | chan = kzalloc(sizeof(struct rchan), GFP_KERNEL); | 584 | chan = kzalloc(sizeof(struct rchan), GFP_KERNEL); |
579 | if (!chan) | 585 | if (!chan) |