Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp252882imp; Thu, 21 Feb 2019 00:24:06 -0800 (PST) X-Google-Smtp-Source: AHgI3IYhF2NeuSKKnBtM99UHEWMl0uUdwhHaekHgzrkFPO+E49hAACQxWQmcFaBDZIo5k+fRPUM0 X-Received: by 2002:a62:d10b:: with SMTP id z11mr38995167pfg.84.1550737446242; Thu, 21 Feb 2019 00:24:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550737446; cv=none; d=google.com; s=arc-20160816; b=kXQ6p9CbbCL8FuBsL/cLAV3DlF3ZkAx8NKh2WQRx3DreYPGlcX4UK3hfRHpzjMz7nC aXAWij+9j9Z8zvFg6xTAv3ASeLoetXoC3bXHWAsnW+N0687XxZ1VUqVBUdbuLyBefEOn 94tLtINFxDgGRHP+AueYGrT8b3d+Pj0PQ/Wobmkr5FXvxjd1viTK57nR2uRBECyRxF2C KhFuzoEKZF0O7dJtXZq1ixOH1gQVZhF0WC1WndiDleKU4DShIRVgLfuRsRXJ6Wf8Z5Bz AIVtHQ+eP1CNUbM3iiKu2krQ2eU4A4ViML+61SeID9r5VIT5lgTcIB1qS+vOwofz+zWf neuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=st4gb9mZxA8JokMcKSfT/J5HqFZrYwqe3Lx5kgtfqAI=; b=ZIjTD7FptbgmuZCA3kjvrmJ/CM8LZb+ne/FTc5/zNPIRGJnORDboJ1lk7aRpHEPZQl aMqNnC3rcmV4ZPN3unffUn8vYkHiQwc/54KOf9DEE/t9/PQXRBbrfpbhxcItXUHSmb+u agPer/BHe03gtTLIen/J5UF+p8QAMe8mB2VZ+BtvGdF9VWEoDI5SYLT/UvLcFyfjsGW8 gvmL/JtIycUlO8jFyMQ+Hd9dUme+FYJ8tHnML1wFAImk+b5dCiHtdSSJm/6awwmOtoha v4tVf5qkRdxiQlgMSPhvPkPiYmF40+l7Rdx4F5DrAM+6WEozUX5yTHER90TZc38m+GtF 34AA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b34si19406108pld.305.2019.02.21.00.23.51; Thu, 21 Feb 2019 00:24:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727482AbfBUIXL (ORCPT + 99 others); Thu, 21 Feb 2019 03:23:11 -0500 Received: from mx2.suse.de ([195.135.220.15]:40940 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725891AbfBUIXL (ORCPT ); Thu, 21 Feb 2019 03:23:11 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 49AE2AD95; Thu, 21 Feb 2019 08:23:10 +0000 (UTC) Date: Thu, 21 Feb 2019 09:23:09 +0100 From: Michal Hocko To: Yue Hu Cc: akpm@linux-foundation.org, rientjes@google.com, joe@perches.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, huyue2@yulong.com, Greg KH Subject: Re: [PATCH] mm/cma_debug: Check for null tmp in cma_debugfs_add_one() Message-ID: <20190221082309.GG4525@dhcp22.suse.cz> References: <20190221040130.8940-1-zbestahu@gmail.com> <20190221040130.8940-2-zbestahu@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190221040130.8940-2-zbestahu@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 21-02-19 12:01:30, Yue Hu wrote: > From: Yue Hu > > If debugfs_create_dir() failed, the following debugfs_create_file() > will be meanless since it depends on non-NULL tmp dentry and it will > only waste CPU resource. The file will be created in the debugfs root. But, more importantly. Greg (CCed now) is working on removing the failure paths because he believes they do not really matter for debugfs and they make code more ugly. More importantly a check for NULL is not correct because you get ERR_PTR after recent changes IIRC. > > Signed-off-by: Yue Hu > --- > mm/cma_debug.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/mm/cma_debug.c b/mm/cma_debug.c > index 2c2c869..3e9d984 100644 > --- a/mm/cma_debug.c > +++ b/mm/cma_debug.c > @@ -169,6 +169,8 @@ static void cma_debugfs_add_one(struct cma *cma, struct dentry *root_dentry) > scnprintf(name, sizeof(name), "cma-%s", cma->name); > > tmp = debugfs_create_dir(name, root_dentry); > + if (!tmp) > + return; > > debugfs_create_file("alloc", 0200, tmp, cma, &cma_alloc_fops); > debugfs_create_file("free", 0200, tmp, cma, &cma_free_fops); > -- > 1.9.1 > -- Michal Hocko SUSE Labs