From patchwork Tue Jun 29 02:35:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12348941 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 44C1DC11F66 for ; Tue, 29 Jun 2021 02:35:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 195B061A1D for ; Tue, 29 Jun 2021 02:35:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 195B061A1D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 714B28D0098; Mon, 28 Jun 2021 22:35:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 69EFF8D008F; Mon, 28 Jun 2021 22:35:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 58BEE8D0098; Mon, 28 Jun 2021 22:35:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0020.hostedemail.com [216.40.44.20]) by kanga.kvack.org (Postfix) with ESMTP id 3093B8D008F for ; Mon, 28 Jun 2021 22:35:09 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 2DF12180CC767 for ; Tue, 29 Jun 2021 02:35:09 +0000 (UTC) X-FDA: 78305194338.30.C0CFE40 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf09.hostedemail.com (Postfix) with ESMTP id EEDF16000103 for ; Tue, 29 Jun 2021 02:35:08 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id ED72F61D00; Tue, 29 Jun 2021 02:35:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1624934108; bh=sU0HuV4KjbIrx60Q32gXd86fZZFa3t7Aek70ZXkfMog=; h=Date:From:To:Subject:In-Reply-To:From; b=NkE1j0dBQJIDhlnU6gPxrbES6UUXNVVWWbg+aNioY9GZm4aB2RY0RZSbEOm8kbSVk dnEeRDGQZDJwwK8xV56dnt8+uSDgqtQmxYOveqK5bM1oMGZ/iCFAePFyJU5od+oVez Em9KGwoC3BMjApaaQLBqRgFRgNGo/xyF1f+UGrz4= Date: Mon, 28 Jun 2021 19:35:07 -0700 From: Andrew Morton To: akpm@linux-foundation.org, linux-mm@kvack.org, mm-commits@vger.kernel.org, tangbin@cmss.chinamobile.com, torvalds@linux-foundation.org, zhangshengju@cmss.chinamobile.com Subject: [patch 035/192] tools/vm/page_owner_sort.c: check malloc() return Message-ID: <20210629023507.bxBh2LOcT%akpm@linux-foundation.org> In-Reply-To: <20210628193256.008961950a714730751c1423@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: EEDF16000103 Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=NkE1j0dB; spf=pass (imf09.hostedemail.com: domain of akpm@linux-foundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Stat-Signature: hfn7ftdu1u6fbo64pyr8abkttdify7wq X-HE-Tag: 1624934108-566525 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Tang Bin Subject: tools/vm/page_owner_sort.c: check malloc() return Link: https://lkml.kernel.org/r/20210506131402.10416-1-tangbin@cmss.chinamobile.com Signed-off-by: Zhang Shengju Signed-off-by: Tang Bin Signed-off-by: Andrew Morton --- tools/vm/page_owner_sort.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/tools/vm/page_owner_sort.c~tools-vm-page_owner_sortc-fix-the-potential-stack-overflow-risk +++ a/tools/vm/page_owner_sort.c @@ -132,6 +132,10 @@ int main(int argc, char **argv) qsort(list, list_size, sizeof(list[0]), compare_txt); list2 = malloc(sizeof(*list) * list_size); + if (!list2) { + printf("Out of memory\n"); + exit(1); + } printf("culling\n");