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=-9.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,T_DKIMWL_WL_HIGH,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 86951C28CC1 for ; Sat, 1 Jun 2019 13:20:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 51FFD272D8 for ; Sat, 1 Jun 2019 13:20:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559395234; bh=8MS0V5tPfk/9WGLTQwnoxCLz2GwEAguIF5tSrT/drqE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Y5lyMxqDNalUaoeDIvMbUClFARgSuI4XeGSlSfpXq4oq60uMNYO8N3CoOMJRzWM6A 4ZLLyMrsrrpClcNPlBPI2qu2UZi9OVhCam1vZ/81zSFJhjQ1d2EBQH9gq6h2sxIViZ soEBX6V+8GdB41VfozdPjG9xnGGWoGF5+DWrJbmI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728320AbfFANUc (ORCPT ); Sat, 1 Jun 2019 09:20:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:47572 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727545AbfFANUY (ORCPT ); Sat, 1 Jun 2019 09:20:24 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6CC5C272E2; Sat, 1 Jun 2019 13:20:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559395223; bh=8MS0V5tPfk/9WGLTQwnoxCLz2GwEAguIF5tSrT/drqE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dNc+7XlDcA2JYbC6KZ/I/xj1hJrjcpa3D2wRfbTGVtLa21hrYFTtv5ghMM5dZ0xx6 nEylOu6zdU0JijeU7japd+L0yHy/WSuBZplmhjiQjncMEVB7Odiqs1mwIbJoSzfh98 YVTPU8eICJuW0CC79Sl3NDxygbSdXuodQm3RF9Ck= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Yue Hu , Anshuman Khandual , Joonsoo Kim , Laura Abbott , Mike Rapoport , Randy Dunlap , Andrew Morton , Linus Torvalds , Sasha Levin , linux-mm@kvack.org Subject: [PATCH AUTOSEL 5.0 014/173] mm/cma.c: fix crash on CMA allocation if bitmap allocation fails Date: Sat, 1 Jun 2019 09:16:46 -0400 Message-Id: <20190601131934.25053-14-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190601131934.25053-1-sashal@kernel.org> References: <20190601131934.25053-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yue Hu [ 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 f4f3a8a57d862..f160ce31ef469 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