From patchwork Thu Mar 23 11:58:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13185584 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 724EBC6FD1D for ; Thu, 23 Mar 2023 11:59:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 15AA76B0075; Thu, 23 Mar 2023 07:59:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 10B5C6B0078; Thu, 23 Mar 2023 07:59:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F15336B007B; Thu, 23 Mar 2023 07:59:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id E49116B0075 for ; Thu, 23 Mar 2023 07:59:45 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A232B1201A5 for ; Thu, 23 Mar 2023 11:59:45 +0000 (UTC) X-FDA: 80600018730.05.3AFE306 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf13.hostedemail.com (Postfix) with ESMTP id E8CDA20019 for ; Thu, 23 Mar 2023 11:59:43 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=PoRZ7T4V; spf=pass (imf13.hostedemail.com: domain of arnd@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=arnd@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679572784; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=N6D8EKximEeE1YEKZBEMXWtQ/lBAW7jUgCvTznvrqiM=; b=Mic5p73dyKII0OiR009PREc83v7QorYgIzeuGRenaowW/Lx42ykU2HDcp8AMK4iI03PhG6 AAMpipce/1TzL5LibETqULnL9+K29Bl123Q+kWtCiPudvUfKM5TV6KOM3Zmz6DqWQGUCqJ 5I38m6hLcXrb3v7Mz8IaxtGNvgMyBmc= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=PoRZ7T4V; spf=pass (imf13.hostedemail.com: domain of arnd@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=arnd@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679572784; a=rsa-sha256; cv=none; b=Dk0Pwt52PkGsXnXjemDlqg4MSRql/qGp9TZ/mbjPJifLUo//raFxcSKhpv5xnKi1CrJOyC HjGm0NvqXj+3aau/Mf4YEVNWuo3bPra0uh+TahrPuBfOGshDY9KlEQhX1e7blsdddcw7sj j6BGuIARO8EgT/EHkjjZHCC+n+okEU0= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 88658B81FDA; Thu, 23 Mar 2023 11:59:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1859EC433D2; Thu, 23 Mar 2023 11:59:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679572781; bh=me8lIKVzX4f4kEhtj/IZ/N62RywMeIeThO/YQFbwteI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PoRZ7T4VeuvD6lVxWJCeAYNQqpd4RILWHk5vcprJ5zLlgoNJl7XH8sN9RE4DNe/6D Gm2fsLvFXKKAhi2TKnz5Y1QJj+hj2GePh81dWspUUTWCHpD6x6h3AntosNQLuaU49A pXS7jvc2FraInbauw8rpnt2muQaZpATfJfiv+TeJXMxwaXx9GwEE7+F9DYgjViQfDO KPiM+NOhvH3zhggkxDwkLvZFehojjyyBNwvyaUsyAvimIOKWwj/v9UM4bsFC/OwzVW BiADB8RPVYiMwojAeD5E7vnJSMNyVfscO1dP6vwSxljAyRbwtFyo0s1pPWVxvJGDA7 T5QhZQ8KyjN1g== From: Arnd Bergmann To: Andrew Morton , Lorenzo Stoakes Cc: Arnd Bergmann , Uladzislau Rezki , Christoph Hellwig , Baoquan He , David Hildenbrand , Andrey Konovalov , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] mm: vmalloc: fix vmap_ram_vread_iter() return value Date: Thu, 23 Mar 2023 12:58:35 +0100 Message-Id: <20230323115903.1483668-2-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230323115903.1483668-1-arnd@kernel.org> References: <20230323115903.1483668-1-arnd@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: 1pwx5mg7xormpmwhnpz7qzez1d4bu1fs X-Rspamd-Queue-Id: E8CDA20019 X-HE-Tag: 1679572783-146716 X-HE-Meta: U2FsdGVkX19khcChOhhEyH857JkVw3HhnQN2XKbHJ20NaziGCDSNtmPQDg6fOj6bY0bh8uvXr7yDGjnd7PlD/u1+eNHljMkNnQq3r5W2r6GoHgJRD+QcPRVUkGCbM2ClwwtrPEXAgZOxVtIxYNulST9M6gC64yov2Wy08/ECUBMxQq6ZmRR6L89xRJHq0EIIJI1lVCPGNbKfvuTNwuIM2ZbEXan93Ph7OTBnsMktW4vTRu6QhYItyje/mZ/REmrsJSOTbaJj7YeLjbi0LURxukFz/3TpiumhZsyEVglhQFDUfJ+lFkTLdUlRU/FeEuVO40dO78/Q427rYZGYBEhbY35+oiC+tQmZpYVmxb0mvg12bz2CphncyV6AkHrDFoKGwrhbddEvaxPcaK8e83p+oWgdFDW8Yt1swfmZRLMHdhL+Ufoc/0CloMUAZiaVQ/PUhUEzWrZMhXu8xzhC1uI83ap+lghEH48teHo4d808hvpOffH4dvIw87zfx2hyb7oK5NW0q8gAKElvTyQmBCwCqZ0t0+l1G1QQQo+CzS6IyFwYc2DSQOrihgT22z/t0rc+NcWeIaD/xhpr0oNC7bg934jUAhjC7PrnXMoqL94Xwb1aQff4jJ1S+JI58SCWUfNOyIhAkBImi4d088y1Wru9DF3cuc/NT91EvX+BU6GuHzo0d4ZD7HttCBr3cUeBMVuonioJOW4d361TUE13jrOwpDa9c6xElBepkgPM5pvg2/nlIVU+PIEJ6N8W0KzsvrTit7uILPDS6ENcplIZSyRlfoxFt6U8kPlTAkzHFlzgJgetYauNa0hcKi887t1g7Gdg8XBc5JnZMwDfFtplo8vsmlWO1zilxI33EkiGIJkFeYOS9KroVPHIgjPcu+4zpKEz1cl+R0jTx2OAsnSEM6MrJl1Qlmor+oetBjQn7O0DuIEA7c8rvmbWAIyP/uvyS4FMrmQbMXpNLgYWfWGHuv2 Ma/siicS 9+3x70OFYoM6V1RpJBsnMqum/ZTa+riIhtguo+G5wnDJGIco7wsm87Y5xnxZjwUDNoW6X/Y9fWv9EVmgNSC3Xhys9SW0dGpEBJXGFkmNXIWi/96wFu3OjstXiDqW/mB3KwPrhSSKYWLWPPpFlsqaCoir/9tiUEpkbPxVlzZ4Y/8ZQA8pgE5mOqiILQUwpNLDi5e8tp0FVcF7K3XbLLhOKy7zH0yL4Km6dNuYiCc0ayu1emOjvUxn687hW9EhYL91jDua9iXTy6QvVkQKNBFfYOO42lgraqw1MF4vi X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Arnd Bergmann The error handling in vmap_ram_vread_iter() can return an uninitialized value in some cases: mm/vmalloc.c:3539:6: error: variable 'remains' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] if (!vb) ^~~ mm/vmalloc.c:3587:17: note: uninitialized use occurs here return count - remains + zero_iter(iter, remains); ^~~~~~~ Move the initialization up a few lines. Fixes: d9cab54f7737 ("mm: vmalloc: convert vread() to vread_iter()") Signed-off-by: Arnd Bergmann --- mm/vmalloc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index ebfa1e9fe6f9..fb216495fe5a 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3521,7 +3521,7 @@ static size_t vmap_ram_vread_iter(struct iov_iter *iter, const char *addr, struct vmap_block *vb; unsigned long offset; unsigned int rs, re; - size_t remains, n; + size_t remains = count, n; /* * If it's area created by vm_map_ram() interface directly, but @@ -3545,7 +3545,6 @@ static size_t vmap_ram_vread_iter(struct iov_iter *iter, const char *addr, goto finished_zero; } - remains = count; for_each_set_bitrange(rs, re, vb->used_map, VMAP_BBMAP_BITS) { size_t copied;