[Sound-open-firmware] [PATCH 2/3] IIR equalizer: Fix a null pointer issue

Seppo Ingalsuo seppo.ingalsuo at linux.intel.com
Mon Jun 12 10:31:14 CEST 2017


The cd->config could be passed as null pointer to eq_iir_setup() if the
previous malloc() would fail.


Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo at linux.intel.com>
---
 src/audio/eq_iir.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/audio/eq_iir.c b/src/audio/eq_iir.c
index a8def32..6c8ddc6 100644
--- a/src/audio/eq_iir.c
+++ b/src/audio/eq_iir.c
@@ -339,9 +339,10 @@ static int eq_iir_cmd(struct comp_dev *dev, int cmd, void *data)
 
 		/* Allocate and make a copy of the blob and setup IIR */
 		cd->config = rmalloc(RZONE_RUNTIME, RFLAGS_NONE, bs);
-		if (cd->config != NULL)
-			memcpy(cd->config, blob->data, bs);
+		if (cd->config == NULL)
+			return -EINVAL;
 
+		memcpy(cd->config, blob->data, bs);
 		eq_iir_setup(cd->iir, cd->config, source->params.pcm->channels);
 		break;
 	case COMP_CMD_MUTE:
-- 
2.11.0



More information about the Sound-open-firmware mailing list