From patchwork Mon Jan 23 08:25:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 92199 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1106262qgi; Sun, 22 Jan 2017 23:28:45 -0800 (PST) X-Received: by 10.55.21.158 with SMTP id 30mr21614253qkv.137.1485156525808; Sun, 22 Jan 2017 23:28:45 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id g57si10210708qta.157.2017.01.22.23.28.45; Sun, 22 Jan 2017 23:28:45 -0800 (PST) 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 36BCB60F01; Mon, 23 Jan 2017 07:28:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id C9E7060EF6; Mon, 23 Jan 2017 07:28:40 +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 DD63460EFA; Mon, 23 Jan 2017 07:28:37 +0000 (UTC) Received: from mail-lf0-f48.google.com (mail-lf0-f48.google.com [209.85.215.48]) by lists.linaro.org (Postfix) with ESMTPS id 9B4DB60EF5 for ; Mon, 23 Jan 2017 07:28:36 +0000 (UTC) Received: by mail-lf0-f48.google.com with SMTP id z134so88654819lff.3 for ; Sun, 22 Jan 2017 23:28:36 -0800 (PST) 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=4IJOjadyPvkxOf7qFQLk3DKizLSsAh4ZRHSd4yVQsRs=; b=fR+t82VJnobPQjQJaGIhk1gQgosu9cg/1ggow/8AeEh1hSIdIx+jgbGD5YMkIaa2hj neFVKg7kxwQckFZmZg7SUAq1KISlRPsxvZvOShXnwj5Z9xtaXXoEcQhfAGijuAdX8yKu 7pkuSV2h2ENk1mk7k2gPQazod70ZdE27Kel8i29ACFyLWIoKzAmnUXr6PPjLJlc8Sq/1 ZSXOi7XuR2nqFW+GLC7EKaNQo7g/8GlI0MqI4WgiSytyRTex/ZKXOxwqsLRORKRrlUIY OMZ18Ir3uEFcHY0W04aU8inNal9REq5vD53iYMCKNzEzOL4RNOYjvl/LEvrmTBphDdIa QflQ== X-Gm-Message-State: AIkVDXLVhYch9doH5yjRH85voeZw4QC3kU+b0C9IeqUIdAHFIplEThT+IxzzbjWhkuYga0mu1ns= X-Received: by 10.25.155.11 with SMTP id d11mr9140711lfe.110.1485156515354; Sun, 22 Jan 2017 23:28:35 -0800 (PST) Received: from erachmi-ericsson.ki.sw.ericsson.se (c-83-233-76-66.cust.bredband2.com. [83.233.76.66]) by smtp.gmail.com with ESMTPSA id 96sm6090613lfp.18.2017.01.22.23.28.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 22 Jan 2017 23:28:34 -0800 (PST) From: Christophe Milard To: mike.holmes@linaro.org, bill.fischofer@linaro.org, lng-odp@lists.linaro.org Date: Mon, 23 Jan 2017 09:25:23 +0100 Message-Id: <1485159923-51866-1-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 Subject: [lng-odp] [PATCHv2] linux-gen: _ishm: checking fstat return value. 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" Hence fixing CID 174663 (Fixes https://bugs.linaro.org/show_bug.cgi?id=2827) Signed-off-by: Christophe Milard --- since V1: -print strerror(errno) and sets __odp_errno (Maxim) -ref to bugzilla bug ID (Mike, Bill) platform/linux-generic/_ishm.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- 2.7.4 Reviewed-by: Bill Fischofer diff --git a/platform/linux-generic/_ishm.c b/platform/linux-generic/_ishm.c index f889834..5ca1067 100644 --- a/platform/linux-generic/_ishm.c +++ b/platform/linux-generic/_ishm.c @@ -818,7 +818,14 @@ int _odp_ishm_reserve(const char *name, uint64_t size, int fd, /* If a file descriptor is provided, get the real size and map: */ if (fd >= 0) { - fstat(fd, &statbuf); + if (fstat(fd, &statbuf) < 0) { + close(fd); + odp_spinlock_unlock(&ishm_tbl->lock); + ODP_ERR("_ishm_reserve failed (fstat failed: %s).\n", + strerror(errno)); + __odp_errno = errno; + return -1; + } len = statbuf.st_size; /* note that the huge page flag is meningless here as huge * page is determined by the provided file descriptor: */