Thanks for reviewing this patch Fred, Frederic Barrat <fbar...@linux.vnet.ibm.com> writes:
> So we are calling functions with an invalid afu argument. We can verify > in the callees the value of the afu pointer, like you're doing here, but > why not tackle it at source and avoid calling the function in the first > place? Couple of reasons: * Having checks for NULL afu at the call sites rather than the functions being called will lead to these checks scattered at more than a few places in code. Many of these functions are called via indirect branch from cxl_backend_ops and have their call sites scattered in the code. Having this check in the called functions is a much smaller change in comparison. * Some of these functions are called are called from outside CXL e.g cxl_dev_context_init(). So putting the NULL check at every caller site might not be possible. * Some funtions need to handle AFU init failures in special way e.g like cxl_vphb_error_detected() need to force a card hotplug so that AFU reinit can be tried. * None of these functions are in any hotpath in the code so having an extra check at the beginning of the code wont have a much performance impact. -- Vaibhav Jain <vaib...@linux.vnet.ibm.com> Linux Technology Center, IBM India Pvt. Ltd.