From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755650Ab2GQPui (ORCPT ); Tue, 17 Jul 2012 11:50:38 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:65250 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755607Ab2GQPue (ORCPT ); Tue, 17 Jul 2012 11:50:34 -0400 From: Joonsoo Kim To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Joonsoo Kim , Michal Nazarewicz , Marek Szyprowski , Minchan Kim , Christoph Lameter Subject: [PATCH 3/4 v3] mm: fix return value in __alloc_contig_migrate_range() Date: Wed, 18 Jul 2012 00:49:16 +0900 Message-Id: <1342540156-3512-1-git-send-email-js1304@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org migrate_pages() can return positive value while at the same time emptying the list of pages it was called with. Such situation means that it went through all the pages on the list some of which failed to be migrated. If that happens, __alloc_contig_migrate_range()'s loop may finish without "++tries == 5" never being checked. This in turn means that at the end of the function, ret may have a positive value, which should be treated as an error. This patch changes __alloc_contig_migrate_range() so that the return statement converts positive ret value into -EBUSY error. Signed-off-by: Joonsoo Kim Cc: Michal Nazarewicz Cc: Marek Szyprowski Cc: Minchan Kim Cc: Christoph Lameter Acked-by: Christoph Lameter Acked-by: Michal Nazarewicz diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 4403009..02d4519 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5673,7 +5673,6 @@ static int __alloc_contig_migrate_range(unsigned long start, unsigned long end) } tries = 0; } else if (++tries == 5) { - ret = ret < 0 ? ret : -EBUSY; break; } @@ -5683,7 +5682,7 @@ static int __alloc_contig_migrate_range(unsigned long start, unsigned long end) } putback_lru_pages(&cc.migratepages); - return ret > 0 ? 0 : ret; + return ret <= 0 ? ret : -EBUSY; } /* -- 1.7.9.5