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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140221154244.GG31902@saruman.home>
Date:	Fri, 21 Feb 2014 09:42:44 -0600
From:	Felipe Balbi <balbi@...com>
To:	Michal Simek <monstr@...str.eu>
CC:	Mark Rutland <mark.rutland@....com>, Felipe Balbi <balbi@...com>,
	Subbaraya Sundeep Bhatta <subbaraya.sundeep.bhatta@...inx.com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	"linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	Subbaraya Sundeep Bhatta <sbhatta@...inx.com>,
	"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>
Subject: Re: [PATCH RFC] usb: gadget: Add xilinx axi usb2 device support

Hi,

On Fri, Feb 21, 2014 at 02:41:03PM +0100, Michal Simek wrote:
> >>> +	/* Map the registers */
> >>> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> >>> +	udc->base_address = devm_ioremap_nocache(&pdev->dev, res->start,
> >>> +						 resource_size(res));
> >>
> >> use devm_ioremap_resource() instead.
> > 
> > Also, res might be NULL. You should check that before dereferencing it.
> 
> yes it is necessary for both cases with devm_ioremap_nocache
> or with devm_ioremap_resource.

read the source Luke:

| void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res)
| {
| 	resource_size_t size;
| 	const char *name;
| 	void __iomem *dest_ptr;
| 
| 	BUG_ON(!dev);
| 
| 	if (!res || resource_type(res) != IORESOURCE_MEM) {
            ^^^^
	    already done for you

| 		dev_err(dev, "invalid resource\n");
| 		return ERR_PTR(-EINVAL);
| 	}
| 
| 	size = resource_size(res);
| 	name = res->name ?: dev_name(dev);
| 
| 	if (!devm_request_mem_region(dev, res->start, size, name)) {
| 		dev_err(dev, "can't request region for resource %pR\n", res);
| 		return ERR_PTR(-EBUSY);
| 	}
| 
| 	if (res->flags & IORESOURCE_CACHEABLE)
| 		dest_ptr = devm_ioremap(dev, res->start, size);
| 	else
| 		dest_ptr = devm_ioremap_nocache(dev, res->start, size);
| 
| 	if (!dest_ptr) {
| 		dev_err(dev, "ioremap failed for resource %pR\n", res);
| 		devm_release_mem_region(dev, res->start, size);
| 		dest_ptr = ERR_PTR(-ENOMEM);
| 	}
| 
| 	return dest_ptr;
| }

-- 
balbi

Download attachment "signature.asc" of type "application/pgp-signature" (820 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ