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

Nilay Shroff <[email protected]> Sat, 1 Aug 2026 19:17:55 +0530
Newsgroups org.infradead.lists.linux-nvme,org.kernel.vger.netdev
Message-ID <[email protected]>
On 7/31/26 1:44 PM, Maurizio Lombardi wrote:
> 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 = inode->i_private;
>> +	struct nvme_debugfs_attr *attr = debugfs_get_aux(file);
>> +	struct nvme_debugfs_ctx *ctx;
>> +	struct seq_file *m;
>> +	int ret;
>> +
>> +	if (attr->get && !attr->get(data))
>> +		return -ENODEV;
>> +
>> +	ctx = kzalloc_obj(*ctx);
>> +	if (WARN_ON_ONCE(!ctx)) {
>> +		ret = -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.
> 

Alright, I'll change it to just return -ENOMEM without producing
a warning, in case kzalloc fails.

Thanks,
--Nilay