Dan Williams wrote: > Ira Weiny wrote: [snip] > > diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h > > index e5d770e26e02..7a891b4641cc 100644 > > --- a/drivers/cxl/cxlmem.h > > +++ b/drivers/cxl/cxlmem.h > > @@ -481,6 +481,8 @@ struct cxl_memdev_state { > > struct cxl_security_state security; > > struct cxl_fw_state fw; > > > > + struct notifier_block cxl_cper_nb; delete this... [snip] > > > > +#define CXL_EVENT_HDR_FLAGS_REC_SEVERITY GENMASK(1, 0) > > +static void cxl_cper_event_call(struct cxl_cper_event_data *ev_data) > > +{ > > + struct cper_cxl_event_devid *device_id = &ev_data->rec->hdr.device_id; > > + struct cxl_dev_state *cxlds = NULL; > > + enum cxl_event_log_type log_type; > > + struct pci_dev *pdev; > > + unsigned int devfn; > > + u32 hdr_flags; > > + > > + devfn = PCI_DEVFN(device_id->device_num, device_id->func_num); > > + pdev = pci_get_domain_bus_and_slot(device_id->segment_num, > > + device_id->bus_num, devfn); > > What if pci_get_domain_bus_and_slot() returned NULL? :-/ yep. > > > + > > + guard(mutex)(&pdev->dev.mutex); > > Lets not open code this since device_lock() is so prevalent it deserves > its own guard() type: > > DEFINE_GUARD(device, struct device *, device_lock(_T), device_unlock(_T)) Good idea. > > > + if (pdev->driver == &cxl_pci_driver) > > + cxlds = pci_get_drvdata(pdev); > > + if (!cxlds) > > + goto out; > > Lets not mix usage of cleanup.h helpers with usage of goto. The helpers > are there to eliminate goto errors. Just add a new helper: > > DEFINE_FREE(pci_dev_put, struct pci_dev *, if (_T) pci_dev_put(_T)) > > ...and declare @pdev as: > > struct pci_dev *pdev __free(pci_dev_put) = NULL; > Even better idea. Done. Thanks, Ira