From patchwork Thu Sep 22 12:13:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 76763 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp6643qgf; Thu, 22 Sep 2016 05:36:25 -0700 (PDT) X-Received: by 10.55.11.3 with SMTP id 3mr1791892qkl.290.1474547785690; Thu, 22 Sep 2016 05:36:25 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id y63si975141qkc.251.2016.09.22.05.36.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 22 Sep 2016 05:36:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:43124 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn3En-0001sk-3K for patch@linaro.org; Thu, 22 Sep 2016 08:36:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53164) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn2uH-0008SF-D1 for qemu-devel@nongnu.org; Thu, 22 Sep 2016 08:15:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn2uC-0006Xl-Bk for qemu-devel@nongnu.org; Thu, 22 Sep 2016 08:15:12 -0400 Received: from mail-lf0-f52.google.com ([209.85.215.52]:36544) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn2uC-0006WU-43 for qemu-devel@nongnu.org; Thu, 22 Sep 2016 08:15:08 -0400 Received: by mail-lf0-f52.google.com with SMTP id g62so65197634lfe.3 for ; Thu, 22 Sep 2016 05:15:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2/p9JUAMYwaJoXsg2RuMPLmmO/QDQ0eO4Fcjb8xA/ms=; b=BT0+CRv/7PhduiP71su5VnfHIGMGLMpSW1a672bDGUc7d1asB76yiyu6U2lAUBQqft v4aC7+DEJ8Cut40NiIXtbf2GuknfCHJ60hPq3Fq1USHPyC8B5ypWNohpxGKIAafqMjbe peWmY5DuMRqRFQZm5DXaUqWmy0pWeQINe8+lQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2/p9JUAMYwaJoXsg2RuMPLmmO/QDQ0eO4Fcjb8xA/ms=; b=WgqFl20/JMM/cOnpMUL0IRR3VqHvDLhbgJfGOcQP+frT3qAacxRND3lVdEtMz7HWkW UJaG+pl7c0dReAAFhPO/9039u4sYFMptrMnvLBzNzPq7gdscjfvBvt+UQ95HcOS3F107 784N2WzUlAZueMKt9xj0iTrUfoxBGIhRqcmOZ/2FX+eE2AoOj7F7+ezF8TKVaP/FXX5G 8ajZ/m5WSyDothtqdZ0+5fHyyk7+37mzxitqK++YrBFee658bkdw5zRHUJfYoZ/hNaG+ oeRdisdfNIn23mLyBC4b8RJCYm1K3slNmIJg8dzNQoQg1XNzBp05og1tOEJMfxQYyFsw H4tA== X-Gm-Message-State: AE9vXwO2JpwHnIkMiatt3L/PUlIQ5LLJFBpWMM5T3Mc74OeuLfIHtuC+/Vk6lsfYxA8gicY8 X-Received: by 10.25.43.208 with SMTP id r199mr725544lfr.140.1474546447092; Thu, 22 Sep 2016 05:14:07 -0700 (PDT) Received: from beaming.home (91-157-170-157.elisa-laajakaista.fi. [91.157.170.157]) by smtp.gmail.com with ESMTPSA id u14sm294378lja.11.2016.09.22.05.14.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Sep 2016 05:14:06 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Thu, 22 Sep 2016 15:13:32 +0300 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.215.52 Subject: [Qemu-devel] [PULL 12/26] linux-user: Fix error handling in flatload.c target_pread() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell The flatload.c target_pread() function is supposed to return 0 on success or negative host errnos; however it wasn't checking lock_user() for failure or returning the errno from the pread() call. Fix these problems (the first of which is noted by Coverity). Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/flatload.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.1.4 diff --git a/linux-user/flatload.c b/linux-user/flatload.c index 42d1079..a35a560 100644 --- a/linux-user/flatload.c +++ b/linux-user/flatload.c @@ -95,7 +95,13 @@ static int target_pread(int fd, abi_ulong ptr, abi_ulong len, int ret; buf = lock_user(VERIFY_WRITE, ptr, len, 0); + if (!buf) { + return -EFAULT; + } ret = pread(fd, buf, len, offset); + if (ret < 0) { + ret = -errno; + } unlock_user(buf, ptr, len); return ret; }