[RFC 1/3] nvme: Return -ENOMEM when kzalloc fails

Christoph Hellwig hch at lst.de
Sun Oct 30 01:02:36 PDT 2022


On Thu, Oct 27, 2022 at 10:26:57AM -0600, Keith Busch wrote:
> On Thu, Oct 27, 2022 at 05:57:22PM +0200, Joel Granados wrote:
> > In nvme_init_non_mdts_limits function we were returning 0 when kzalloc
> > failed. This patch corrects this behavior and return -ENOMEM
> > Fixes: 5befc7c26e5a ("nvme: implement non-mdts command limits")
> 
> I'm pretty sure I had this returning 0 on purpose. We can proceed
> without this optional structure.

Well, we could.  But I don't think it really is a good idea.  Why I think
failing major resource allocation (e.g. HMB) and just continuing limited,
doing that for these tiny kmallocs that the kernel basically never fails
tends to create a lot of confusion and hard to test code pathes.



More information about the Linux-nvme mailing list