You've already forked hexagonrpc
mirror of
https://github.com/linux-msm/hexagonrpc.git
synced 2026-02-25 13:13:52 -08:00
fastrpc: hexagonrpcd: listener: compute out_count before zero check
The amount of output buffers needed should be computed before the check,
otherwise it checks an uninitialized value. Initialize it first so that
the zero check works as intended.
Fixes: 9ea9bed77b ("fastrpc: hexagonrpcd: listener: do not attempt to allocate zero outbufs")
This commit is contained in:
@@ -73,6 +73,7 @@ static struct fastrpc_io_buffer *allocate_outbufs(const struct fastrpc_function_
|
||||
off_t off;
|
||||
uint32_t *sizes;
|
||||
|
||||
out_count = def->out_bufs + (def->out_nums && 1);
|
||||
/*
|
||||
* POSIX allows malloc to return a non-NULL pointer to a zero-size area
|
||||
* in memory. Since the code below assumes non-zero size if the pointer
|
||||
@@ -81,7 +82,6 @@ static struct fastrpc_io_buffer *allocate_outbufs(const struct fastrpc_function_
|
||||
if (out_count == 0)
|
||||
return NULL;
|
||||
|
||||
out_count = def->out_bufs + (def->out_nums && 1);
|
||||
out = malloc(sizeof(struct fastrpc_io_buffer) * out_count);
|
||||
if (out == NULL)
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user