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 D8512C31E49 for ; Thu, 13 Jun 2019 16:07:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A74A0215EA for ; Thu, 13 Jun 2019 16:07:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560442024; bh=fv8bfEeCFUkwXzWiI3k/sImyYmTTUj5rlS+GDRSg9Yk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=qKpO91YMlVIpeltNST5bHc2z+YtF1hn0W6Xwg7JZT98skD6A/cIKDIQdDlZzrwdhi t24Tn/NDVUiHqTO0mGMAlUI0A2AqhHeGQO44XuzLUqkigulZiu5HzhETo0s3xZNiGO 7T8ISWidchxkkWWze5hg0W9nDdpZmqCO2pHQwygI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390532AbfFMQG1 (ORCPT ); Thu, 13 Jun 2019 12:06:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:34442 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731310AbfFMIpr (ORCPT ); Thu, 13 Jun 2019 04:45:47 -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 389332173C; Thu, 13 Jun 2019 08:45:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560415546; bh=fv8bfEeCFUkwXzWiI3k/sImyYmTTUj5rlS+GDRSg9Yk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tQ56MudSpo721wwtBdA5NNXIxs6nPtBT2H2CpFyFoKP+mamgUDg7gNtaXAisWYwYR yTA7iotNwwAV4nu36zUKVN2fPxlIjqfHvE73di2/KUdxO5LMGUAGi0QKQmXGmH2ruE jpwKsw2oPuAIBE4cmSCEFiAl1spgRdJkDHuBc2cg= 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 5.1 016/155] mm/cma.c: fix crash on CMA allocation if bitmap allocation fails Date: Thu, 13 Jun 2019 10:32:08 +0200 Message-Id: <20190613075653.681074527@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190613075652.691765927@linuxfoundation.org> References: <20190613075652.691765927@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 bb2d333ffcb3..8cb95cd1193a 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