Re: [PATCH 1/2] quickstats, kernel sample collector

From: Greg KH
Date: Wed Feb 26 2020 - 03:12:17 EST


On Tue, Feb 25, 2020 at 06:30:26PM -0800, Luigi Rizzo wrote:
> +static int __init ks_init(void)
> +{
> + ks_root = debugfs_create_dir("kstats", NULL);
> + if (IS_ERR_OR_NULL(ks_root)) {
> + pr_warn("kstats: cannot create debugfs root\n");
> + return PTR_ERR(ks_root);
> + }

Do not check debugfs_create_* calls as there is no need to. Just take
the return value (if you care to use it again) and move on.

Also, the check you made here is incorrect :)

> + ks_control_dentry = debugfs_create_file("_control", 0644, ks_root,
> + NULL, &ks_file_ops);
> + if (IS_ERR_OR_NULL(ks_control_dentry)) {
> + pr_warn("kstats: cannot create kstats/_control\n");
> + debugfs_remove_recursive(ks_root);
> + return PTR_ERR(ks_control_dentry);
> + }

Same here, just call debugfs_create_file and move on.

You do this same thing in other places too.

thanks,

greg k-h