From patchwork Fri Oct 11 05:46:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nipun Gupta X-Patchwork-Id: 175915 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp312489ill; Thu, 10 Oct 2019 23:03:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqy0DtlknKfYQMwbkesut7Pe6Y5OuU/HpZdY5NtsbjgT2X5R7BCz2FFXfiAGAE1AwMpEcq3z X-Received: by 2002:aa7:cfc2:: with SMTP id r2mr268387edy.229.1570773827574; Thu, 10 Oct 2019 23:03:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570773827; cv=none; d=google.com; s=arc-20160816; b=BCrOLKh01e/VoapN60VUjjh5866fQqWg9cK37wk+nJ/x5g5ZiwPq85Jji1K6RgoGQr 9EPsyW/urryTlwGONbb2IvTi0sxQ1YX+h8f4F29F8YbSVQLkQu0hnuOnd8LloQcUNv5B VWfL3YUPdpwVewpuZMUzKjVmDIUAtXqTTB8utMYzR6EhVxy0EiwTYk1khIkXcUHyconM pV65T7nYKDTW0gkQMOVwIluODARBwiFscchBOPtngWVQDiAz9HVf/HsyV3ANMGO7GkgT 8dLzLhJTsy5OuiUVFBkM03wsjAsYT2OFufQZC4ObEE092WxIxjM/uCKEKwdg0bEfQTTk uD0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:cc:to:from; bh=oz3rre3cU5Bh7wSL3PrKrjAKg0kHnX+VedT9WemeVz4=; b=bvBeNOs/ihJ2g25eRpzxoeM3sFO8Eh3rJcKK/r9ZndGWLhRxGVGmgegcjB7g+wRC2Q nHgYTQS/eZpMK9A5K8l8FoU5ps35lfC+SRPfdLSbGeUQkdBQHUalTW1NOJnjOz/pWo6o RFbd+r0yvScqxcQTlHIRXFXXVyVBkptVLXxzsmZbP3Eviux75PoFWIM/kzR2aD7yhig3 XPf7fPFfV3xvCLKzANxPPbZ7yKqqFoLvJvs+VzBx60+Jz+ZtAq7cElwQgMi2ER9kFEYK Fe+nYwAs0LxyH0dqQkJTFdjnOAXpKOcW1vHYYeTEF4HDSXs3fsBY3nU62bwkGb5YHNwk I4Fw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id f2si4755848ejw.335.2019.10.10.23.03.47; Thu, 10 Oct 2019 23:03:47 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8FCBB1E97D; Fri, 11 Oct 2019 08:02:53 +0200 (CEST) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by dpdk.org (Postfix) with ESMTP id 658491E983 for ; Fri, 11 Oct 2019 08:02:43 +0200 (CEST) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 30C542004CD; Fri, 11 Oct 2019 08:02:43 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 7C80D2004EB; Fri, 11 Oct 2019 08:02:40 +0200 (CEST) Received: from GDB1.ap.freescale.net (GDB1.ap.freescale.net [10.232.132.179]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id CB4BC402E4; Fri, 11 Oct 2019 14:02:36 +0800 (SGT) From: Nipun Gupta To: dev@dpdk.org Cc: ferruh.yigit@intel.com, hemant.agrawal@nxp.com, sachin.saxena@nxp.com, Shreyansh Jain Date: Fri, 11 Oct 2019 11:16:57 +0530 Message-Id: <20191011054657.21931-10-nipun.gupta@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191011054657.21931-1-nipun.gupta@nxp.com> References: <20191011054657.21931-1-nipun.gupta@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH 9/9] bus/fslmc: sanitize device name parsing for clarity X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Shreyansh Jain remove unneccessary dup and free Signed-off-by: Shreyansh Jain --- drivers/bus/fslmc/fslmc_bus.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) -- 2.17.1 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