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: 74034 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp2869663wrt; Thu, 23 Mar 2023 05:06:54 -0700 (PDT) X-Google-Smtp-Source: AK7set8G7jkFIo6f3ckA6FxfxunOuHKy5ukIg+Y56cF2aXnO4WBZHfwTQPoOIXCsM78sabM3irQ+ X-Received: by 2002:a17:906:fcc1:b0:8f3:9ee9:f1bc with SMTP id qx1-20020a170906fcc100b008f39ee9f1bcmr5202133ejb.13.1679573214262; Thu, 23 Mar 2023 05:06:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679573214; cv=none; d=google.com; s=arc-20160816; b=KO9DfZ9U6ax0LCvIveRmFWOb58fM4KJheiITc5q7xP+7yf5UdWeJY+5i33hXFbzeYL xQ1BGDIL/JQ5ylQjYMos1hSEv6E4si5/XyNVtSTiSN9UCOMPsZ9YwUgrdSNljYHBQ5Bo LZI3nYUbjgpnh3suJ34uMFRWdhqlOZxDKE62F0kTGcFDicJ1yxS++0RPzxysrfN/jjhb PVxIyPXDt5K8Oe/dWb5W//QVpTLv+2jXneKjPz1yknJQ/bWyc0TwgdVpHYyryW/mXQ5o 3R4QF126lNvC0DCDPearIynQX68HZ7MPvJ3uTMcMc6lzZSBM2u3t6QuNn550w7J64gzT 8/5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=N6D8EKximEeE1YEKZBEMXWtQ/lBAW7jUgCvTznvrqiM=; b=d3f7f8v4LisBPiZZs2YGIlVt341BTO/9+3NJ0dGHT3rx2WKOwCX7xBBO/IM5t8R2dr Egq+QhTTvlKg6FetwnO8aT6uguAIFvrgjdJHznyTNFfHaMBuR/k4DEpH/4DAkfmXK/mp V+xPHedfzmAHGvqGSeiKL/FuvbS9qrMwv4C43+aFKVErJfe4Lt62yqe8qzitqcMNaPd7 6IjDPc8R1bcaBwDBaq5cKFeL1Qa5zigNcgG8GEJn55pdPR7nxO+Qdc2FJqGMDh9UDiwo KFmXH48FpmR6tPJa/0A5mMipXMtU18+OhFTtSEw93iIiGx3Ls8WBlK54BwPTJQlvuF4o sbcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PoRZ7T4V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cb6-20020a170906a44600b0093322cf202csi15313013ejb.28.2023.03.23.05.06.29; Thu, 23 Mar 2023 05:06:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PoRZ7T4V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229532AbjCWMCB (ORCPT + 99 others); Thu, 23 Mar 2023 08:02:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231486AbjCWMB1 (ORCPT ); Thu, 23 Mar 2023 08:01:27 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5268594 for ; Thu, 23 Mar 2023 04:59:46 -0700 (PDT) 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 97641B8208F for ; 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-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761160162901209486?= X-GMAIL-MSGID: =?utf-8?q?1761160162901209486?= 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;