From patchwork Tue Jan 5 14:14:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Stancek X-Patchwork-Id: 11999131 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B79F6C433DB for ; Tue, 5 Jan 2021 14:14:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 314BE22AAB for ; Tue, 5 Jan 2021 14:14:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 314BE22AAB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 542DF8D007E; Tue, 5 Jan 2021 09:14:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4CDFA8D006E; Tue, 5 Jan 2021 09:14:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3935E8D007E; Tue, 5 Jan 2021 09:14:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0021.hostedemail.com [216.40.44.21]) by kanga.kvack.org (Postfix) with ESMTP id 1E59A8D006E for ; Tue, 5 Jan 2021 09:14:39 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D25E3181AEF00 for ; Tue, 5 Jan 2021 14:14:38 +0000 (UTC) X-FDA: 77671917036.08.stick31_1a06502274d9 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin08.hostedemail.com (Postfix) with ESMTP id 9ED4E1819E76F for ; Tue, 5 Jan 2021 14:14:38 +0000 (UTC) X-HE-Tag: stick31_1a06502274d9 X-Filterd-Recvd-Size: 3127 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Tue, 5 Jan 2021 14:14:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609856077; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=FFhE3QWiTuwXxm7OOOvYxjR2y1OcGJ9OkHckxaAUKOg=; b=HkfUZ4FPRZV4RDZunJns5q05ofI0gDwxc/4bbhC0GkiaZ9fDQhRsf+zi9Z3ROizdt6OGBc KA6VQLTZpR9LKbBUOqM4UBQIzccpQ3/CMpDkh69Q/ffC0ycWPQXhqy9OCdjDTHnqygc3Px c3an0OtU6SeFdSft8ajHnum/Ty10p9g= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-230-WmPIvgh9OzCVoS7xFTbaoQ-1; Tue, 05 Jan 2021 09:14:35 -0500 X-MC-Unique: WmPIvgh9OzCVoS7xFTbaoQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8CC5E180A095; Tue, 5 Jan 2021 14:14:33 +0000 (UTC) Received: from janakin.usersys.redhat.com (unknown [10.36.110.76]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64C925D6D3; Tue, 5 Jan 2021 14:14:30 +0000 (UTC) From: Jan Stancek To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: ziy@nvidia.com, shy828301@gmail.com, jack@suse.cz, willy@infradead.org, mgorman@suse.de, mhocko@suse.com, songliubraving@fb.com, akpm@linux-foundation.org, jstancek@redhat.com Subject: [PATCH] mm: migrate: initialize err in do_migrate_pages Date: Tue, 5 Jan 2021 15:14:20 +0100 Message-Id: <456a021c7ef3636d7668cec9dcb4a446a4244812.1609855564.git.jstancek@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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: After commit 236c32eb1096 ("mm: migrate: clean up migrate_prep{_local}")', do_migrate_pages can return uninitialized variable 'err' (which is propagated to user-space as error) when 'from' and 'to' nodesets are identical. This can be reproduced with LTP migrate_pages01, which calls migrate_pages() with same set for both old/new_nodes. Add 'err' initialization back. Fixes: 236c32eb1096 ("mm: migrate: clean up migrate_prep{_local}") Cc: Zi Yan Cc: Yang Shi Cc: Jan Kara Cc: Matthew Wilcox Cc: Mel Gorman Cc: Michal Hocko Cc: Song Liu Cc: Andrew Morton Signed-off-by: Jan Stancek Acked-by: Michal Hocko --- mm/mempolicy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 8cf96bd21341..2c3a86502053 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1111,7 +1111,7 @@ int do_migrate_pages(struct mm_struct *mm, const nodemask_t *from, const nodemask_t *to, int flags) { int busy = 0; - int err; + int err = 0; nodemask_t tmp; migrate_prep();