From mboxrd@z Thu Jan 1 00:00:00 1970 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=-8.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 C9BDAC43613 for ; Thu, 20 Jun 2019 18:29:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A491520675 for ; Thu, 20 Jun 2019 18:29:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561055365; bh=6wO+vFiS1LrwWSS8RoW5P5hLyxd6mGBhYKlxC1jwV7Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=FXS8r3/OxWMQWRpv9Ybg8Juh1mema4h04xa4l/uV/SVne39FqVEsr99bo1z9hGnh/ BsjKEv1v1MhqYTYLsEA6aI4ROpczL4UEXKkxTnp6JRdz2EBslcmJJ+VkQeWLOv4Wv2 yYddEpYvKJwU6/fb4QWXG+oZQWwz/Mgcq8JMA3F0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727465AbfFTSCg (ORCPT ); Thu, 20 Jun 2019 14:02:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:53306 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727460AbfFTSCg (ORCPT ); Thu, 20 Jun 2019 14:02:36 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F0D27204FD; Thu, 20 Jun 2019 18:02:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561053755; bh=6wO+vFiS1LrwWSS8RoW5P5hLyxd6mGBhYKlxC1jwV7Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DNCTOH9KCW9iE/+vmo1NrUJVQhkBJn1FDklvdrrtsB7qonHAIisrUz+ikAxaRlfih R7SO+K1lXpaH+Y13PjNpaokEPhvPSWkM0wDJQzX/fIxMUp+woA//kpZ0LJvcknvdor G2Sj8V2RJigpfaBx8w7R7uJWYbsW8aLxd6VUfArI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yue Hu , Anshuman Khandual , Joonsoo Kim , Laura Abbott , Mike Rapoport , Randy Dunlap , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.9 008/117] mm/cma.c: fix crash on CMA allocation if bitmap allocation fails Date: Thu, 20 Jun 2019 19:55:42 +0200 Message-Id: <20190620174352.485426267@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190620174351.964339809@linuxfoundation.org> References: <20190620174351.964339809@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org [ Upstream commit 1df3a339074e31db95c4790ea9236874b13ccd87 ] f022d8cb7ec7 ("mm: cma: Don't crash on allocation if CMA area can't be activated") fixes the crash issue when activation fails via setting cma->count as 0, same logic exists if bitmap allocation fails. Link: http://lkml.kernel.org/r/20190325081309.6004-1-zbestahu@gmail.com Signed-off-by: Yue Hu Reviewed-by: Anshuman Khandual Cc: Joonsoo Kim Cc: Laura Abbott Cc: Mike Rapoport Cc: Randy Dunlap Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- mm/cma.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/cma.c b/mm/cma.c index b5d8847497a3..4ea0f32761c1 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -100,8 +100,10 @@ static int __init cma_activate_area(struct cma *cma) cma->bitmap = kzalloc(bitmap_size, GFP_KERNEL); - if (!cma->bitmap) + if (!cma->bitmap) { + cma->count = 0; return -ENOMEM; + } WARN_ON_ONCE(!pfn_valid(pfn)); zone = page_zone(pfn_to_page(pfn)); -- 2.20.1