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=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 DF06DC31E49 for ; Thu, 13 Jun 2019 16:29:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AA86E20644 for ; Thu, 13 Jun 2019 16:29:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560443390; bh=lQkuSuLoO+Klp0cPventqHyggeqvBvY2y55UVlqmXWI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=YdtTRFRt9CyUOyiMt/ru2PXD0tPOPvrjS8s2Sc7yZBX32uDzBrEfMDmgaYPsuprfO 4WhXaTj79UvGI+zIxeHp2vMGvFB/9MtebJuxf1rmcNiiHH3QPvXoOx6Gi7FlZfBJsT 3yduiNzTKSsB/aFVKSNQHufonUUBPrIrGUKDDs7k= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732100AbfFMQ3u (ORCPT ); Thu, 13 Jun 2019 12:29:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:52940 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730922AbfFMIfL (ORCPT ); Thu, 13 Jun 2019 04:35:11 -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 B27DE206E0; Thu, 13 Jun 2019 08:35:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560414911; bh=lQkuSuLoO+Klp0cPventqHyggeqvBvY2y55UVlqmXWI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O2yeUaJymRCns3fsdFcK+AWpyrsz60L88TRa1ov4+gg+C0ZzlHYPzgvBWkoo18ebt L9WrUieHbeAbgU/53lXp/PtPKEvax3ARgYBo9ErmGrAeiUEGrk/GFFaKohSfs6NJLp x5sNRv0VbXakqsxZrEJLvZDF8u+goRvJZXsPHatg= 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.14 09/81] mm/cma.c: fix crash on CMA allocation if bitmap allocation fails Date: Thu, 13 Jun 2019 10:32:52 +0200 Message-Id: <20190613075649.745754240@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190613075649.074682929@linuxfoundation.org> References: <20190613075649.074682929@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 5749c9b3b5d0..cba4fe1b284c 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -105,8 +105,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