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: <5165CAE0.3070207@cogentembedded.com>
Date:	Thu, 11 Apr 2013 00:26:08 +0400
From:	Sergei Shtylyov <sergei.shtylyov@...entembedded.com>
To:	Sebastian Hesselbarth <sebastian.hesselbarth@...il.com>
CC:	Lennert Buytenhek <buytenh@...tstofly.org>,
	Andrew Lunn <andrew@...n.ch>,
	Jason Cooper <jason@...edaemon.net>,
	Florian Fainelli <florian@...nwrt.org>, netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] net: mv643xx_eth: use managed devm_kzalloc

On 04/11/2013 12:17 AM, Sebastian Hesselbarth wrote:
>
>>
>>> This patch moves shared private data kzalloc to managed devm_kzalloc 
>>> and
>>> cleans now unneccessary kfree and error handling.
>>>
>>> Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@...il.com>
>>> ---
>>> Note that there is also an ioremap call, that could be transferred to
>>> devm_ioremap_resource. But as long as mv643xx_eth and mvmdio iomem
>>> resources overlap, this will throw -EBUSY.
>>>
>>> Cc: Lennert Buytenhek <buytenh@...tstofly.org>
>>> Cc: Andrew Lunn <andrew@...n.ch>
>>> Cc: Jason Cooper <jason@...edaemon.net>
>>> Cc: Florian Fainelli <florian@...nwrt.org>
>>> Cc: netdev@...r.kernel.org
>>> Cc: linux-kernel@...r.kernel.org
>>> ---
>>> drivers/net/ethernet/marvell/mv643xx_eth.c | 17 ++++-------------
>>> 1 file changed, 4 insertions(+), 13 deletions(-)
>>>
>>> diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c
>>> b/drivers/net/ethernet/marvell/mv643xx_eth.c
>>> index bbe6104..955baab 100644
>>> --- a/drivers/net/ethernet/marvell/mv643xx_eth.c
>>> +++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
>>> @@ -2547,25 +2547,22 @@ static int mv643xx_eth_shared_probe(struct
>>> platform_device *pdev)
>>> struct mv643xx_eth_shared_private *msp;
>>> const struct mbus_dram_target_info *dram;
>>> struct resource *res;
>>> - int ret;
>>> if (!mv643xx_eth_version_printed++)
>>> pr_notice("MV-643xx 10/100/1000 ethernet driver version %s\n",
>>> mv643xx_eth_driver_version);
>>> - ret = -EINVAL;
>>> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>> if (res == NULL)
>>> - goto out;
>>> + return -EINVAL;
>>> - ret = -ENOMEM;
>>> - msp = kzalloc(sizeof(*msp), GFP_KERNEL);
>>> + msp = devm_kzalloc(&pdev->dev, sizeof(*msp), GFP_KERNEL);
>>> if (msp == NULL)
>>> - goto out;
>>> + return -ENOMEM;
>>> msp->base = ioremap(res->start, resource_size(res));
>>> if (msp->base == NULL)
>>> - goto out_free;
>>> + return -EADDRNOTAVAIL;
>>
>> -ENOMEM usually.
>
> Sergei,
>
> I was looking at the example for devm_request_and_ioremap() in
> lib/devres.c. There it is -EADDRNOTAVAIL which is returned on
> failing ioremap.

    This is a recommended value to return if this function fails, to be 
precise --
regardless of the reason.
    With mere ioremap(), the value has always been -ENOMEM.

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ