[PATCH] vme: ca91cx42: fix memleak in ca91cx42_dma_list_add
From: Dinghao Liu
Date: Sun Aug 23 2020 - 02:28:08 EST
When we encounter invalid data width or address space,
entry should be freed just like what we've done in the
previous error paths.
Signed-off-by: Dinghao Liu <dinghao.liu@xxxxxxxxxx>
---
drivers/vme/bridges/vme_ca91cx42.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/vme/bridges/vme_ca91cx42.c b/drivers/vme/bridges/vme_ca91cx42.c
index ea938dc29c5e..1c464afd9d4e 100644
--- a/drivers/vme/bridges/vme_ca91cx42.c
+++ b/drivers/vme/bridges/vme_ca91cx42.c
@@ -1100,7 +1100,8 @@ static int ca91cx42_dma_list_add(struct vme_dma_list *list,
break;
default:
dev_err(dev, "Invalid data width\n");
- return -EINVAL;
+ retval = -EINVAL;
+ goto err_cycle;
}
/* Setup address space */
@@ -1122,8 +1123,8 @@ static int ca91cx42_dma_list_add(struct vme_dma_list *list,
break;
default:
dev_err(dev, "Invalid address space\n");
- return -EINVAL;
- break;
+ retval = -EINVAL;
+ goto err_cycle;
}
if (vme_attr->cycle & VME_SUPER)
--
2.17.1