lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <6578f7fc4e04a_22539529429@iweiny-mobl.notmuch>
Date:   Tue, 12 Dec 2023 16:17:00 -0800
From:   Ira Weiny <ira.weiny@...el.com>
To:     Dan Williams <dan.j.williams@...el.com>,
        Ira Weiny <ira.weiny@...el.com>,
        Jonathan Cameron <jonathan.cameron@...wei.com>,
        Smita Koralahalli <Smita.KoralahalliChannabasappa@....com>,
        Shiju Jose <shiju.jose@...wei.com>
CC:     Yazen Ghannam <yazen.ghannam@....com>,
        Davidlohr Bueso <dave@...olabs.net>,
        Dave Jiang <dave.jiang@...el.com>,
        Alison Schofield <alison.schofield@...el.com>,
        Vishal Verma <vishal.l.verma@...el.com>,
        "Ard Biesheuvel" <ardb@...nel.org>, <linux-efi@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>, <linux-cxl@...r.kernel.org>,
        Ira Weiny <ira.weiny@...el.com>
Subject: Re: [PATCH v2 7/7] cxl/memdev: Register for and process CPER events

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ