From patchwork Mon Feb 2 12:43:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 44122 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 533712034D for ; Mon, 2 Feb 2015 12:44:18 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id h11sf18350994wiw.1 for ; Mon, 02 Feb 2015 04:44:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=HjinDN+qkT/7jK7GfZ9t2wWcsVIWS6rDgWkxcwORkNE=; b=mC9tvhqzgxJE7HEgq5yg5ZfxceIGL/hGpEDk3C/rgrjpecXOVkE/4YT85ByjeFnLzc +Kg+JwifT7fUJirqPeNcv9KKQNgDdzXPBrDwmVEqxB7ZAbxG01aFQ2XBh31ZbB1dLBPp pRbTxzHIji31o1Dj1EPfFiljtd3AQVQ1xED6RJDO+qw18Mb6Q0kIZH/Dijl4peAtrFSd Vs2WkV0QmzY0FW6zy4SGh+hjOPdSJPUWPMtNGjvVDv4WUmEBFRfozNORBL/nU9E4TjE3 fD8frac7aoka8FGgQRCMKUBAMWT7Z+26aKKHre7Y3dgRlylsqMdQwpAy7agz8Tvq+pfU sP+A== X-Gm-Message-State: ALoCoQk2a3GuPUwyse5DrxE0BAE0trVPYKVO6b0YgDKEiBViZURQntpmpdAsyE+D5LQj1SJNs8lX X-Received: by 10.180.12.146 with SMTP id y18mr550wib.6.1422881057562; Mon, 02 Feb 2015 04:44:17 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.229 with SMTP id v5ls523226lav.55.gmail; Mon, 02 Feb 2015 04:44:17 -0800 (PST) X-Received: by 10.112.167.68 with SMTP id zm4mr19222728lbb.93.1422881057193; Mon, 02 Feb 2015 04:44:17 -0800 (PST) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id or2si16849349lbb.91.2015.02.02.04.44.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Feb 2015 04:44:17 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by mail-la0-f47.google.com with SMTP id hz20so40218278lab.6 for ; Mon, 02 Feb 2015 04:44:17 -0800 (PST) X-Received: by 10.152.8.1 with SMTP id n1mr18562535laa.47.1422881057066; Mon, 02 Feb 2015 04:44:17 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp1270940lbj; Mon, 2 Feb 2015 04:44:16 -0800 (PST) X-Received: by 10.52.73.166 with SMTP id m6mr9838812vdv.13.1422881055431; Mon, 02 Feb 2015 04:44:15 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id k12si8837566vdj.96.2015.02.02.04.44.13 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 02 Feb 2015 04:44:15 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YIGMN-000126-7v; Mon, 02 Feb 2015 12:44:11 +0000 Received: from mail-la0-f47.google.com ([209.85.215.47]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YIGMG-00011W-Ox for lng-odp@lists.linaro.org; Mon, 02 Feb 2015 12:44:04 +0000 Received: by mail-la0-f47.google.com with SMTP id hz20so40215771lab.6 for ; Mon, 02 Feb 2015 04:43:58 -0800 (PST) X-Received: by 10.152.161.204 with SMTP id xu12mr14792238lab.12.1422881038548; Mon, 02 Feb 2015 04:43:58 -0800 (PST) Received: from localhost.localdomain (broadband-46-188-125-106.2com.net. [46.188.125.106]) by mx.google.com with ESMTPSA id aa2sm440527lbc.17.2015.02.02.04.43.56 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Feb 2015 04:43:57 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Mon, 2 Feb 2015 15:43:51 +0300 Message-Id: <1422881031-25105-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 X-Topics: patch Subject: [lng-odp] [PATCH] linux-generic: pktio check for NULL entry X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: maxim.uvarov@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 CID: 85427 https://bugs.linaro.org/show_bug.cgi?id=1175 get_pktio_entry() can return NULL entry then it can be derefenced inside is_free(entry). Signed-off-by: Maxim Uvarov --- platform/linux-generic/include/odp_packet_io_internal.h | 8 ++++++-- platform/linux-generic/odp_packet_io.c | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 488818c..2c766f0 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -22,6 +22,7 @@ extern "C" { #include #include #include +#include #include #include @@ -67,10 +68,13 @@ extern void *pktio_entry_ptr[]; static inline pktio_entry_t *get_pktio_entry(odp_pktio_t id) { - if (odp_unlikely(id == ODP_PKTIO_INVALID || - id > ODP_CONFIG_PKTIO_ENTRIES)) + if (odp_unlikely(id == ODP_PKTIO_INVALID)) return NULL; + if (odp_unlikely(id > ODP_CONFIG_PKTIO_ENTRIES)) + ODP_ABORT("pktio limit %d/%d exceed\n", + id, ODP_CONFIG_PKTIO_ENTRIES); + return pktio_entry_ptr[id - 1]; } #ifdef __cplusplus diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index bdb690e..cfb8d00 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -320,7 +320,7 @@ odp_pktio_t odp_pktio_lookup(const char *dev) for (i = 1; i <= ODP_CONFIG_PKTIO_ENTRIES; ++i) { entry = get_pktio_entry(i); - if (is_free(entry)) + if (!entry || is_free(entry)) continue; lock_entry(entry);