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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no 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 58CCCC432BE for ; Thu, 29 Jul 2021 13:55:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 39EFD60EBC for ; Thu, 29 Jul 2021 13:55:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237843AbhG2Nz3 (ORCPT ); Thu, 29 Jul 2021 09:55:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237620AbhG2Nz0 (ORCPT ); Thu, 29 Jul 2021 09:55:26 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE480C061765; Thu, 29 Jul 2021 06:55:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=//JteJBlPO/oxjTtV3LASZaFA4G6WCHzkWs4cs97Saw=; b=iZFUmVL3DjXeQg65XLBHJKYW+r ij7voxBE+IDPgeuSPz7voqUndWCfKEe4BwM0Nx49Uer0h//8+3oD9o62dZ6iJ7MeKTIiC9GwN6pja 8Q25jshIVHOAXS/XavTefpp71qH3SOdLJSvYQVsr/wKa091xMOpafpfGWhUnh+aPDUXFW+Lh6rYLQ ZY/8spCb23lWoAi6nVPNAJbrFvBI4yoijzs/Rj77fHaz1wgpd6yvZEXNBV+xI/GYSLqe9TOtLA7sk pkqyZy7ewtzkjO/bGQf6v94jGRPAWzXQ90AeFGQkRITOa2ns2kghh3nmSN6zbJa9KwL7hmNpQyoTM xWxCLu8w==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m96Sd-00H7zD-ER; Thu, 29 Jul 2021 13:52:50 +0000 Date: Thu, 29 Jul 2021 14:52:31 +0100 From: Matthew Wilcox To: Miaohe Lin Cc: hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org, shakeelb@google.com, guro@fb.com, alexs@kernel.org, richard.weiyang@gmail.com, songmuchun@bytedance.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org Subject: Re: [PATCH 4/5] mm, memcg: avoid possible NULL pointer dereferencing in mem_cgroup_init() Message-ID: References: <20210729125755.16871-1-linmiaohe@huawei.com> <20210729125755.16871-5-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210729125755.16871-5-linmiaohe@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 29, 2021 at 08:57:54PM +0800, Miaohe Lin wrote: > rtpn might be NULL in very rare case. We have better to check it before > dereferencing it. Since memcg can live with NULL rb_tree_per_node in > soft_limit_tree, warn this case and continue. Why would we need to warn? the GFP flags don't contain NOWARN, so we already know an allocation failed. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthew Wilcox Subject: Re: [PATCH 4/5] mm, memcg: avoid possible NULL pointer dereferencing in mem_cgroup_init() Date: Thu, 29 Jul 2021 14:52:31 +0100 Message-ID: References: <20210729125755.16871-1-linmiaohe@huawei.com> <20210729125755.16871-5-linmiaohe@huawei.com> Mime-Version: 1.0 Return-path: DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=//JteJBlPO/oxjTtV3LASZaFA4G6WCHzkWs4cs97Saw=; b=iZFUmVL3DjXeQg65XLBHJKYW+r ij7voxBE+IDPgeuSPz7voqUndWCfKEe4BwM0Nx49Uer0h//8+3oD9o62dZ6iJ7MeKTIiC9GwN6pja 8Q25jshIVHOAXS/XavTefpp71qH3SOdLJSvYQVsr/wKa091xMOpafpfGWhUnh+aPDUXFW+Lh6rYLQ ZY/8spCb23lWoAi6nVPNAJbrFvBI4yoijzs/Rj77fHaz1wgpd6yvZEXNBV+xI/GYSLqe9TOtLA7sk pkqyZy7ewtzkjO/bGQf6v94jGRPAWzXQ90AeFGQkRITOa2ns2kghh3nmSN6zbJa9KwL7hmNpQyoTM xWxCLu8w==; Content-Disposition: inline In-Reply-To: <20210729125755.16871-5-linmiaohe-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Miaohe Lin Cc: hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org, mhocko-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, vdavydov.dev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org, shakeelb-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org, guro-b10kYP2dOMg@public.gmane.org, alexs-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, richard.weiyang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, songmuchun-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org, linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On Thu, Jul 29, 2021 at 08:57:54PM +0800, Miaohe Lin wrote: > rtpn might be NULL in very rare case. We have better to check it before > dereferencing it. Since memcg can live with NULL rb_tree_per_node in > soft_limit_tree, warn this case and continue. Why would we need to warn? the GFP flags don't contain NOWARN, so we already know an allocation failed.