Re: [RESEND PATCH v2 3/4] nvme: add debugfs helpers for NVMe drivers

"Maurizio Lombardi" <[email protected]> Fri, 31 Jul 2026 10:14:26 +0200
Newsgroups org.infradead.lists.linux-nvme,org.kernel.vger.netdev
Message-ID <[email protected]>
On Fri Jul 31, 2026 at 9:39 AM CEST, Nilay Shroff wrote:
> +static int nvme_debugfs_open(struct inode *inode, struct file *file)
> +{
> +	void *data =3D inode->i_private;
> +	struct nvme_debugfs_attr *attr =3D debugfs_get_aux(file);
> +	struct nvme_debugfs_ctx *ctx;
> +	struct seq_file *m;
> +	int ret;
> +
> +	if (attr->get && !attr->get(data))
> +		return -ENODEV;
> +
> +	ctx =3D kzalloc_obj(*ctx);
> +	if (WARN_ON_ONCE(!ctx)) {
> +		ret =3D -ENOMEM;
> +		goto out;
> +	}

Just a nit, I don't think that raising a warning just because
kzalloc() returned NULL is a good idea as failures can naturally
occur under OOM conditions and aren't bugs.

Maurizio