[9/9] bus/fslmc: sanitize device name parsing for clarity
diff mbox series

Message ID 20191011054657.21931-10-nipun.gupta@nxp.com
State Superseded
Headers show
Series
  • DPAA and FSLMC driver fixes and cleanup
Related show

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation fail Compilation issues

Commit Message

Nipun Gupta Oct. 11, 2019, 5:46 a.m. UTC
From: Shreyansh Jain <shreyansh.jain@nxp.com>

remove unneccessary dup and free

Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
---
 drivers/bus/fslmc/fslmc_bus.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

Patch
diff mbox series

diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index eff15f25d..251f148da 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -236,8 +236,9 @@  rte_fslmc_parse(const char *name, void *addr)
 {
 	uint16_t dev_id;
 	char *t_ptr;
-	char *sep = NULL;
+	const char *sep;
 	uint8_t sep_exists = 0;
+	int ret = -1;
 
 	DPAA2_BUS_DEBUG("Parsing dev=(%s)", name);
 
@@ -267,10 +268,11 @@  rte_fslmc_parse(const char *name, void *addr)
 		} else {
 			DPAA2_BUS_DEBUG("Invalid device for matching (%s).",
 					name);
+			ret = -EINVAL;
 			goto err_out;
 		}
 	} else
-		sep = strdup(name);
+		sep = name;
 
 jump_out:
 	/* Validate device name */
@@ -284,23 +286,23 @@  rte_fslmc_parse(const char *name, void *addr)
 	    strncmp("dpdmai", sep, 6) &&
 	    strncmp("dpdmux", sep, 6)) {
 		DPAA2_BUS_DEBUG("Unknown or unsupported device (%s)", sep);
+		ret = -EINVAL;
 		goto err_out;
 	}
 
 	t_ptr = strchr(sep, '.');
 	if (!t_ptr || sscanf(t_ptr + 1, "%hu", &dev_id) != 1) {
 		DPAA2_BUS_ERR("Missing device id in device name (%s)", sep);
+		ret = -EINVAL;
 		goto err_out;
 	}
 
 	if (addr)
 		strcpy(addr, sep);
 
-	return 0;
+	ret = 0;
 err_out:
-	if (!sep_exists && sep)
-		free(sep);
-	return -EINVAL;
+	return ret;
 }
 
 static int