Ver código fonte

Merge "asoc: Fix a memory leak issue when nvmem read returns invalid length"

qctecmdr 4 anos atrás
pai
commit
dfa5675e0b
1 arquivos alterados com 7 adições e 1 exclusões
  1. 7 1
      asoc/bengal.c

+ 7 - 1
asoc/bengal.c

@@ -6810,10 +6810,16 @@ static int msm_asoc_machine_probe(struct platform_device *pdev)
 	}
 	buf = nvmem_cell_read(cell, &len);
 	nvmem_cell_put(cell);
-	if (IS_ERR_OR_NULL(buf) || len <= 0 || len > sizeof(32)) {
+	if (IS_ERR_OR_NULL(buf)) {
 		dev_dbg(&pdev->dev, "%s: FAILED to read nvmem cell \n", __func__);
 		goto ret;
 	}
+	if (len <= 0 || len > sizeof(u32)) {
+		dev_dbg(&pdev->dev, "%s: nvmem cell length out of range: %d\n",
+			__func__, len);
+		kfree(buf);
+		goto ret;
+	}
 	memcpy(&adsp_var_idx, buf, len);
 	kfree(buf);
 	va_disable = adsp_var_idx;