Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5653353img; Wed, 27 Mar 2019 12:30:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqyoAXOsycvqS4cUsyvVatOB1PzTErZFsV9snMULXUBFCaNaj/dCkkcm7GGiEXRg74ZwKr35 X-Received: by 2002:a63:b902:: with SMTP id z2mr37153552pge.428.1553715044016; Wed, 27 Mar 2019 12:30:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553715044; cv=none; d=google.com; s=arc-20160816; b=zJn/EPUWaBqnblgmKy5uiET0jozYG1Dpq8gieZxu00o6G7gup0tOB26hmLkMIATX7i diKEH3g0UijbO5Ft+E24PCJKwFVIhMCUdEd6GArEUj2YSKKDEuO+DsaxjVkfiJt1+gt5 VYaaxYfOEUcBWR2fa+hkaKdKTtjOn3Tkc7yeTam2Av51Xa5vVi39/L9hOoiqBFPO7660 WKcwsP7JtNYrmUJHAnHHwPYJBSPX7WwDCiyVXsN1fWVLqKAfhMxv/R+RsHBY/H5gNU/S eQe7idUSJ/jvWupu/nyxLxhzeOV/RYu8cXYo3rxb8WgSBQsa5KEcNQ4tRVM3ISc1kMx2 kYpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=k0AkTHPgA2O6nUBi3XOpT5HZUMd9XCxodgd3dbhYSMw=; b=hK3dsvII9tT4fMmuJEMgjWWZEiPqzNA/lEyHYqAqcJ8rTrhkq7Ng7yDkLuAARhtxb7 faMv0tdi4qUNzz5uAXq/yA/2qiFXHmOGmigPB8Hzaf+eE3gQD/nu/Ydz7op/mNULp2f/ fLzu4XIj7C3vDo1tVqGomqJLMPUwTRuc24xX4WGCdoX/wzVatpUGIXVRMgF0f0cvJ29W qAQ7TMiqEhsE/iJK1DDiVcdffEKh0bcS9ONjlm9Bv8YaDvH5/BYRAoqLyZ9sHqy5L2wA X6Ct4PpcqS/sFoWLcJnNV0VOb705qaY/F99HOAp5qFdfQWnNI0/46AQ5ApsS+vRmi2Qu 0lvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qKJDa9lq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k91si20135502pld.87.2019.03.27.12.30.28; Wed, 27 Mar 2019 12:30:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qKJDa9lq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732854AbfC0SDt (ORCPT + 99 others); Wed, 27 Mar 2019 14:03:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:44106 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732685AbfC0SDr (ORCPT ); Wed, 27 Mar 2019 14:03:47 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A9AB42087C; Wed, 27 Mar 2019 18:03:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553709827; bh=MGfIoXnzyNJ/KAFrw5ZJrFi7P/sOO+b797C3j3DpCrs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qKJDa9lqPCT5FrQKRqlbe33Y1Ye8nJS7oPjbXYzBZXdORbP2sT2Gk9qQ/a+zaOe+r 56eY7JaZIzN0iAPiS8P7be/uC6PxgIAFcyBrhSvdPoWSPmaep2ZwWuIFnw4qKCwHN4 ZhUQpFgGkEsWbo2bsOhgFsFweXmOBPHTka2uJitQ= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dave Hansen , Dan Williams , Dave Jiang , Ross Zwisler , Vishal Verma , Tom Lendacky , Andrew Morton , Michal Hocko , linux-nvdimm@lists.01.org, linux-mm@kvack.org, Huang Ying , Fengguang Wu , Borislav Petkov , Yaowei Bai , Takashi Iwai , Jerome Glisse , Benjamin Herrenschmidt , Paul Mackerras , linuxppc-dev@lists.ozlabs.org, Keith Busch , Sasha Levin Subject: [PATCH AUTOSEL 5.0 061/262] mm/resource: Return real error codes from walk failures Date: Wed, 27 Mar 2019 13:58:36 -0400 Message-Id: <20190327180158.10245-61-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Hansen [ Upstream commit 5cd401ace914dc68556c6d2fcae0c349444d5f86 ] walk_system_ram_range() can return an error code either becuase *it* failed, or because the 'func' that it calls returned an error. The memory hotplug does the following: ret = walk_system_ram_range(..., func); if (ret) return ret; and 'ret' makes it out to userspace, eventually. The problem s, walk_system_ram_range() failues that result from *it* failing (as opposed to 'func') return -1. That leads to a very odd -EPERM (-1) return code out to userspace. Make walk_system_ram_range() return -EINVAL for internal failures to keep userspace less confused. This return code is compatible with all the callers that I audited. Signed-off-by: Dave Hansen Reviewed-by: Bjorn Helgaas Acked-by: Michael Ellerman (powerpc) Cc: Dan Williams Cc: Dave Jiang Cc: Ross Zwisler Cc: Vishal Verma Cc: Tom Lendacky Cc: Andrew Morton Cc: Michal Hocko Cc: linux-nvdimm@lists.01.org Cc: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org Cc: Huang Ying Cc: Fengguang Wu Cc: Borislav Petkov Cc: Yaowei Bai Cc: Takashi Iwai Cc: Jerome Glisse Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: linuxppc-dev@lists.ozlabs.org Cc: Keith Busch Signed-off-by: Dan Williams Signed-off-by: Sasha Levin --- kernel/resource.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/resource.c b/kernel/resource.c index 915c02e8e5dd..ca7ed5158cff 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -382,7 +382,7 @@ static int __walk_iomem_res_desc(resource_size_t start, resource_size_t end, int (*func)(struct resource *, void *)) { struct resource res; - int ret = -1; + int ret = -EINVAL; while (start < end && !find_next_iomem_res(start, end, flags, desc, first_lvl, &res)) { @@ -462,7 +462,7 @@ int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, unsigned long flags; struct resource res; unsigned long pfn, end_pfn; - int ret = -1; + int ret = -EINVAL; start = (u64) start_pfn << PAGE_SHIFT; end = ((u64)(start_pfn + nr_pages) << PAGE_SHIFT) - 1; -- 2.19.1