From patchwork Wed Apr 12 19:41:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 97341 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp415794qgf; Wed, 12 Apr 2017 12:41:26 -0700 (PDT) X-Received: by 10.55.169.193 with SMTP id s184mr46054548qke.137.1492026086027; Wed, 12 Apr 2017 12:41:26 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id n3si11684413qkb.31.2017.04.12.12.41.25; Wed, 12 Apr 2017 12:41:25 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 54C0464814; Wed, 12 Apr 2017 19:41:25 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 3A752636F4; Wed, 12 Apr 2017 19:41:23 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id E28A7637B0; Wed, 12 Apr 2017 19:41:21 +0000 (UTC) Received: from mail-oi0-f50.google.com (mail-oi0-f50.google.com [209.85.218.50]) by lists.linaro.org (Postfix) with ESMTPS id C151A636AC for ; Wed, 12 Apr 2017 19:41:19 +0000 (UTC) Received: by mail-oi0-f50.google.com with SMTP id g204so44024224oib.1 for ; Wed, 12 Apr 2017 12:41:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=S/16hK40UBTA0TpvIRDkJGOoGyyk8l44eXVTBfvZj+s=; b=qET3j+XbhNLYC4ZL1GiL9HU3WxcPW4h1kBg7FOGTtrWJUYgOZIQiMMFTyCUAv/w87y YU41EPjorsfqK4IUKRZ60xodS46p3ufT6GhLC+Eec4Sjd9gUc3RWTj+kd5p7GZSnuW0b gy87k3wDzY5Co+674AqEUSFtDxma/FxACWZFceBBx5YUZx34YPjB4cf403h15+TbjdIf 4y776X+YQjkw+0iCPRITXZJhZp3qIpNcRNK9J5z8ZVDHn3WzmF11OKgKXm4sRSBMUmup /sLdg5RSViSQSmU1g2DSqEA0nZc56ijprJqMGiLl5hMXzwtHtDyJA+w1/klFUO9H+7wX ymOQ== X-Gm-Message-State: AN3rC/6B4lh2Otch4NvNyhIX3XB1XGKMHgr9ExTeMvHitEinMu36clbu6wgXKuqvCWzlobKgr8E= X-Received: by 10.202.76.145 with SMTP id z139mr7424726oia.142.1492026079085; Wed, 12 Apr 2017 12:41:19 -0700 (PDT) Received: from localhost.localdomain (cpe-70-121-83-241.austin.res.rr.com. [70.121.83.241]) by smtp.gmail.com with ESMTPSA id j11sm6052098oth.12.2017.04.12.12.41.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Apr 2017 12:41:18 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Wed, 12 Apr 2017 14:41:14 -0500 Message-Id: <20170412194114.17538-1-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.9.3 Subject: [lng-odp] [PATCHv2] example: l3fwd: check rc from odph_eth_addr_parse() X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Resolve Bug https://bugs.linaro.org/show_bug.cgi?id=2779 by checking the return code from odph_eth_addr_parse() and failing the call if dst_mac is unparseable. Signed-off-by: Bill Fischofer --- Changes in v2: - Don't forget to free(local) (Maxim comment) example/l3fwd/odp_l3fwd_db.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 2.9.3 diff --git a/example/l3fwd/odp_l3fwd_db.c b/example/l3fwd/odp_l3fwd_db.c index 082b2c2..0670aa4 100644 --- a/example/l3fwd/odp_l3fwd_db.c +++ b/example/l3fwd/odp_l3fwd_db.c @@ -394,7 +394,10 @@ int create_fwd_db_entry(char *input, char **oif, uint8_t **dst_mac) *oif = entry->oif; break; case 2: - odph_eth_addr_parse(&entry->dst_mac, token); + if (odph_eth_addr_parse(&entry->dst_mac, token) < 0) { + free(local); + return -1; + } *dst_mac = entry->dst_mac.addr; break;