Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp43415imu; Tue, 22 Jan 2019 13:28:16 -0800 (PST) X-Google-Smtp-Source: ALg8bN7wthlP5/wT0EQ+JTzVzY5j4eiPZrHoYJozPsgCD+yXH+/1Z3RWA8zZsDwmIlYXwf8ObbnJ X-Received: by 2002:a17:902:8d8e:: with SMTP id v14mr35627966plo.133.1548192496866; Tue, 22 Jan 2019 13:28:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548192496; cv=none; d=google.com; s=arc-20160816; b=yl/sZv4RjlZ62jTIVE5+HdxhYnBd8K/rLWCf4FOLO91hfQ7PsbTdQat8xBhlMvAaS4 DTRGDuTz9tCe7in6fqBg+xP/b1lp3iuwe8VnJ20Q2in+ICjVskLlCTuOm9NI8Dw9UwTi CQOnFTBNS/clQUDdvRz5orty0btsE4wOXAf70LlHiFdriX59BHeeMp7hkNIQblCMYfKU itrBSOYT5BF3Hlqh2TXBT8cyjDs+Bic7UVgQS2bDg2us1maEaaSPVkt6mwNzxKOv7rog DcUtdzpmSaNEWFf2PfQHFiKiR3QvlsoY++I9vPngW0YjlCRPZcqvZjgU0XyNIjRo1AFv HXOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=qA73U3orqts/aQvhT/E9hNnoUEIPSLYn2QJd+UKDOHA=; b=Ox+SHNTvejeleAqWj5GTkOaxyJzN2ZJorkKyFbZssYZL527GVwZCMl6H2XaeY0IwuF VM0chgCdlG+LFuKwelQ4BLmyAXAt7TW/VkSvssLeugg1iFvDMdox2IVyb4h5P1fQrOeA Q7Tgo8BslwltnvD9njgK3TVqJvVBVoHkNhB2em8TneyGMq6AYtV2ol1+Y0EBR2LqLmPA gQKKbqn0gxI1JFXtjNddREtK48wF32mknfZ6vmkWFGCjHB1SVjSi2Jnl/qGsY/BxcSNK aRCNFQXbaR30Obfl/aLZz8QXxRPsSxZ0XMBRscuhL/s6leKchsODieR3PuzKb6H9ycPz rfsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=nnYtZQKI; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3si16957299pld.282.2019.01.22.13.28.01; Tue, 22 Jan 2019 13:28:16 -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; dkim=pass header.i=@chromium.org header.s=google header.b=nnYtZQKI; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726804AbfAVV0L (ORCPT + 99 others); Tue, 22 Jan 2019 16:26:11 -0500 Received: from mail-vs1-f65.google.com ([209.85.217.65]:35299 "EHLO mail-vs1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726175AbfAVV0L (ORCPT ); Tue, 22 Jan 2019 16:26:11 -0500 Received: by mail-vs1-f65.google.com with SMTP id e7so20844vsc.2 for ; Tue, 22 Jan 2019 13:26:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qA73U3orqts/aQvhT/E9hNnoUEIPSLYn2QJd+UKDOHA=; b=nnYtZQKIEw2X+lcZ7kxyFOE1X6P+2PGFEMJ/kFQKu+qPYt5cDrw9QYFujLbhzq/H5N ixJpF8CVtwbN/n/fiVb5Z68y7iUVBapOuCjDbmz5NxPlOY9/Dxgm8BLLv/R+h1XC5cNL cEjSCkCGm6EnG0T8KY3vRbxOOQ3ncK9o1HsJw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qA73U3orqts/aQvhT/E9hNnoUEIPSLYn2QJd+UKDOHA=; b=r8/8ATjvK03aA4FArazjzGyHH5jKfHJG/kfIvZVUsP1FiOZk19tL2gOuxZQ7nRtokr lceCLxsNPjBpicvrZ8l5sgYXYZ4sa2d/7Vklsd15b/BQbGHT4B56eBCxVbNh5lr5VtZZ Cmi90q3XzxGdTqRNJ4nOqSw/xYYOBzh9wKn5dAm17LqVIalc0WNwRq7VMWegN5qoDvxE UpFFC1r/lhFPYHlO/t0gnBvJC5dpzIHcbHYEzjXkBc/DP6WnEex9rmJlWseyyxWetsm5 aa2tzUR7LJXutjIHoCsHVJqIRpKFCu4WYPlCxvEPldVJwCloKLPb0UMP6sHboU9Iujvx 0CNw== X-Gm-Message-State: AJcUukdF/KT9fzFEuL19jod/qjm6pPsNqYHhddVEwR6ei7nMDdoeYP3B DlXVOEtz6qE0aWuJX1O2Y29OS4OvZP8= X-Received: by 2002:a67:f114:: with SMTP id n20mr15264217vsk.90.1548192369684; Tue, 22 Jan 2019 13:26:09 -0800 (PST) Received: from mail-vs1-f53.google.com (mail-vs1-f53.google.com. [209.85.217.53]) by smtp.gmail.com with ESMTPSA id n206sm72042605vkn.36.2019.01.22.13.26.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Jan 2019 13:26:08 -0800 (PST) Received: by mail-vs1-f53.google.com with SMTP id n13so13104vsk.4 for ; Tue, 22 Jan 2019 13:26:07 -0800 (PST) X-Received: by 2002:a67:2c13:: with SMTP id s19mr14586369vss.172.1548192366962; Tue, 22 Jan 2019 13:26:06 -0800 (PST) MIME-Version: 1.0 References: <20190122144114.9816-1-gregkh@linuxfoundation.org> <20190122144114.9816-3-gregkh@linuxfoundation.org> In-Reply-To: <20190122144114.9816-3-gregkh@linuxfoundation.org> From: Kees Cook Date: Wed, 23 Jan 2019 10:25:53 +1300 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/4] arm: dump: no need to check return value of debugfs_create functions To: Greg Kroah-Hartman Cc: Catalin Marinas , Kevin Hilman , Russell King , Will Deacon , LKML , linux-arm-kernel , Jinbum Park , Laura Abbott Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 23, 2019 at 3:41 AM Greg Kroah-Hartman wrote: > > When calling debugfs functions, there is no need to ever check the > return value. The function can work or not, but the code logic should > never do something different based on this. > > Cc: Russell King > Cc: Jinbum Park > Cc: Kees Cook > Cc: Laura Abbott > Cc: linux-arm-kernel@lists.infradead.org > Signed-off-by: Greg Kroah-Hartman Do you mean that it bubbles up to an initcall, and the return value is meaningless there? This seems fine to me... Reviewed-by: Kees Cook -Kees > --- > arch/arm/include/asm/ptdump.h | 9 +++------ > arch/arm/mm/dump.c | 4 ++-- > arch/arm/mm/ptdump_debugfs.c | 8 ++------ > 3 files changed, 7 insertions(+), 14 deletions(-) > > diff --git a/arch/arm/include/asm/ptdump.h b/arch/arm/include/asm/ptdump.h > index 3ebf9718288d..0c2d3d0d4cc6 100644 > --- a/arch/arm/include/asm/ptdump.h > +++ b/arch/arm/include/asm/ptdump.h > @@ -21,13 +21,10 @@ struct ptdump_info { > > void ptdump_walk_pgd(struct seq_file *s, struct ptdump_info *info); > #ifdef CONFIG_ARM_PTDUMP_DEBUGFS > -int ptdump_debugfs_register(struct ptdump_info *info, const char *name); > +void ptdump_debugfs_register(struct ptdump_info *info, const char *name); > #else > -static inline int ptdump_debugfs_register(struct ptdump_info *info, > - const char *name) > -{ > - return 0; > -} > +static inline void ptdump_debugfs_register(struct ptdump_info *info, > + const char *name) { } > #endif /* CONFIG_ARM_PTDUMP_DEBUGFS */ > > void ptdump_check_wx(void); > diff --git a/arch/arm/mm/dump.c b/arch/arm/mm/dump.c > index 084779c5c893..eb385a500ed0 100644 > --- a/arch/arm/mm/dump.c > +++ b/arch/arm/mm/dump.c > @@ -450,7 +450,7 @@ void ptdump_check_wx(void) > static int ptdump_init(void) > { > ptdump_initialize(); > - return ptdump_debugfs_register(&kernel_ptdump_info, > - "kernel_page_tables"); > + ptdump_debugfs_register(&kernel_ptdump_info, "kernel_page_tables"); > + return 0; > } > __initcall(ptdump_init); > diff --git a/arch/arm/mm/ptdump_debugfs.c b/arch/arm/mm/ptdump_debugfs.c > index be8d87be4b93..598b636615a2 100644 > --- a/arch/arm/mm/ptdump_debugfs.c > +++ b/arch/arm/mm/ptdump_debugfs.c > @@ -24,11 +24,7 @@ static const struct file_operations ptdump_fops = { > .release = single_release, > }; > > -int ptdump_debugfs_register(struct ptdump_info *info, const char *name) > +void ptdump_debugfs_register(struct ptdump_info *info, const char *name) > { > - struct dentry *pe; > - > - pe = debugfs_create_file(name, 0400, NULL, info, &ptdump_fops); > - return pe ? 0 : -ENOMEM; > - > + debugfs_create_file(name, 0400, NULL, info, &ptdump_fops); > } > -- > 2.20.1 > -- Kees Cook