From 7a8ed190e8e22fff64386eea080a2c8a32d64840 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Mon, 15 Oct 2018 19:20:26 +0300 Subject: [PATCH] eqctl: Add check for calloc() success and return 0 in exit This patch adds the missed details into the code. Signed-off-by: Seppo Ingalsuo --- eqctl/eqctl.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/eqctl/eqctl.c b/eqctl/eqctl.c index 843a047c0..8963c5cb4 100644 --- a/eqctl/eqctl.c +++ b/eqctl/eqctl.c @@ -196,6 +196,12 @@ int main(int argc, char *argv[]) */ buffer_size = ctrl_size + 2 * sizeof(unsigned int); user_data = calloc(1, buffer_size); + if (!user_data) { + fprintf(stderr, + "Error: Failed to allocate buffer for user data.\n"); + exit(EXIT_FAILURE); + } + user_data[0] = SOF_CTRL_CMD_BINARY; if (set) { fprintf(stdout, "Applying configuration \"%s\" ", setup); @@ -242,4 +248,5 @@ int main(int argc, char *argv[]) } } free(user_data); + return 0; }