From patchwork Thu Feb 26 15:52:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 45183 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3BE7C20674 for ; Thu, 26 Feb 2015 15:53:24 +0000 (UTC) Received: by lbvp9 with SMTP id p9sf9114608lbv.1 for ; Thu, 26 Feb 2015 07:53:23 -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=nApDA3FaNyYYnJFGc95iZgyB2FI8K8FrOJ721xCiUu4=; b=BhfKCjaIX3pSl6HloSANkT8LKlJ2w0RXLyy8VOjbxcOu7euPbOhMd6HB8HMzVxAhxo WY0x6mnXk2sVF1rxbnyAkR+JDtqYhO4sDpKyKUrx71DGjEyB7D75iXwvWuSGL+z+Rc4X 7m2knT5mHWUYOCIqUcgZ6wonmYNeBP2RWQlT/Qu6Nk9O1DoOOqBfZZAVHOlirkv9wTn1 KSW8PKZExHqob93SpwsfCfoXJnEmVRBjvgcYswdaxEhs6P+oX61uilNchCavZwGyrEMk d3GTFhuHr4/kd5vVx1jkf0oHBKYyZcwkdfPq37ZxEmfrsUD7xk7QPnilEiOJBpy9icUV JmHA== X-Gm-Message-State: ALoCoQkI/b5UrpAubfuRpXlRNOBk4mIIRm/yooCFRw0umwo65/xx5zjh4YqlpNkEPmGg1GZ7LdsV X-Received: by 10.152.29.97 with SMTP id j1mr1410146lah.3.1424966003146; Thu, 26 Feb 2015 07:53:23 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.225.132 with SMTP id rk4ls57591lac.79.gmail; Thu, 26 Feb 2015 07:53:23 -0800 (PST) X-Received: by 10.112.219.135 with SMTP id po7mr8053937lbc.111.1424966003002; Thu, 26 Feb 2015 07:53:23 -0800 (PST) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id t9si900618lal.77.2015.02.26.07.53.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Feb 2015 07:53:22 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by labge10 with SMTP id ge10so11855016lab.12 for ; Thu, 26 Feb 2015 07:53:22 -0800 (PST) X-Received: by 10.152.28.5 with SMTP id x5mr8077863lag.112.1424966002850; Thu, 26 Feb 2015 07:53:22 -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 h5csp3387790lbj; Thu, 26 Feb 2015 07:53:22 -0800 (PST) X-Received: by 10.140.22.8 with SMTP id 8mr18834495qgm.72.1424966000739; Thu, 26 Feb 2015 07:53:20 -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 r1si1034983qak.115.2015.02.26.07.53.19 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 26 Feb 2015 07:53:20 -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 1YR0kX-0007VG-1Z; Thu, 26 Feb 2015 15:53:17 +0000 Received: from mail-lb0-f175.google.com ([209.85.217.175]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YR0kR-0007V8-2q for lng-odp@lists.linaro.org; Thu, 26 Feb 2015 15:53:11 +0000 Received: by lbjb6 with SMTP id b6so11779733lbj.2 for ; Thu, 26 Feb 2015 07:53:05 -0800 (PST) X-Received: by 10.152.7.38 with SMTP id g6mr8239703laa.65.1424965984878; Thu, 26 Feb 2015 07:53:04 -0800 (PST) Received: from localhost.localdomain (ppp91-76-170-205.pppoe.mtu-net.ru. [91.76.170.205]) by mx.google.com with ESMTPSA id n9sm281747lbp.0.2015.02.26.07.53.03 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 26 Feb 2015 07:53:04 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Thu, 26 Feb 2015 18:52:36 +0300 Message-Id: <1424965956-14188-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] [PATCHv2] 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.41 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 --- v2: do not call odp_abort on excced pktio entries. platform/linux-generic/include/odp_packet_io_internal.h | 10 ++++++++-- platform/linux-generic/odp_packet_io.c | 2 +- 2 files changed, 9 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 47b8992..25d49fb 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,15 @@ extern void *pktio_entry_ptr[]; static inline pktio_entry_t *get_pktio_entry(odp_pktio_t id) { - if (odp_unlikely(id == ODP_PKTIO_INVALID || - _odp_typeval(id) > ODP_CONFIG_PKTIO_ENTRIES)) + if (odp_unlikely(id == ODP_PKTIO_INVALID)) return NULL; + if (odp_unlikely(_odp_typeval(id) > ODP_CONFIG_PKTIO_ENTRIES)) { + ODP_DBG("pktio limit %d/%d exceed\n", + _odp_typeval(id), ODP_CONFIG_PKTIO_ENTRIES); + return NULL; + } + return pktio_entry_ptr[_odp_typeval(id) - 1]; } #ifdef __cplusplus diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 21f0c17..b04ce8b 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -339,7 +339,7 @@ odp_pktio_t odp_pktio_lookup(const char *dev) for (i = 1; i <= ODP_CONFIG_PKTIO_ENTRIES; ++i) { entry = get_pktio_entry(_odp_cast_scalar(odp_pktio_t, i)); - if (is_free(entry)) + if (!entry || is_free(entry)) continue; lock_entry(entry);