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.7 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 DB892C31E45 for ; Thu, 13 Jun 2019 16:19:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A817F2147A for ; Thu, 13 Jun 2019 16:19:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560442786; bh=PuYNLRFYktJBwpfgdZA3wjG/njTMVcgHDj7Fu63EghY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=bDPsH4h31cv0o3fky+Pr+Yg29DpY6ICUFLAfnVhcBb1fmku6xukCrEXoKiWBxWi/O WGW/LGgo/twzi/VQQujmaXhZrCFz9jooQbVvwHbEJa6UL8BZd2MVwG2OK8Bh+juolz apj3FDUrN+sBfKimmiS3XENWVKYiZ35hO7BmkP5g= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391924AbfFMQTg (ORCPT ); Thu, 13 Jun 2019 12:19:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:57344 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731094AbfFMIjy (ORCPT ); Thu, 13 Jun 2019 04:39:54 -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 1081821479; Thu, 13 Jun 2019 08:39:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560415193; bh=PuYNLRFYktJBwpfgdZA3wjG/njTMVcgHDj7Fu63EghY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O2/oBkQms5RjQsbtIknObR49qRykjgUeYghBovCp3f5TagiU3hvxLp3J+aHyVCYUw V7VlV+UtfnueDg6N8PvO1t63TG4Mj1j9iGCxbMGhu9phB3qjIhE030/2MpGWlFq2L7 FGNFBbkYN4rlGWnrsDISGerrJSEOdW0WzlDoCy3o= 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.19 010/118] mm/cma.c: fix crash on CMA allocation if bitmap allocation fails Date: Thu, 13 Jun 2019 10:32:28 +0200 Message-Id: <20190613075644.271087701@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190613075643.642092651@linuxfoundation.org> References: <20190613075643.642092651@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 bfe9f5397165..6ce6e22f82d9 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -106,8 +106,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