[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1390969124.11756.43.camel@joe-AO722>
Date: Tue, 28 Jan 2014 20:18:44 -0800
From: Joe Perches <joe@...ches.com>
To: Manish Badarkhe <badarkhe.manish@...il.com>
Cc: linux-kernel@...r.kernel.org, gregkh@...uxfoundation.org,
broonie@...nel.org, lgirdwood@...il.com
Subject: Re: [PATCH V3 1/2] devres: introduce API "devm_kstrdup"
On Wed, 2014-01-29 at 09:33 +0530, Manish Badarkhe wrote:
> This patch introduces "devm_kstrdup" API so that the
> device's driver can allocate memory and copy string.
[]
> diff --git a/drivers/base/devres.c b/drivers/base/devres.c
[]
> @@ -791,6 +791,32 @@ void * devm_kmalloc(struct device *dev, size_t size, gfp_t gfp)
> EXPORT_SYMBOL_GPL(devm_kmalloc);
>
> /**
> + * devm_kstrdup - Allocate resource managed space and
> + * and copy an existing string
> + * @dev: Device to allocate memory for
> + * @s: the string to duplicate
> + * @size: Allocation size
Why is size necessary at all?
I think it should be calculated by strlen
> +char *devm_kstrdup(struct device *dev,
> + const char *s, size_t size, gfp_t gfp)
> +{
> + char *buf;
> +
> + if (!s)
> + return NULL;
> +
> + buf = devm_kzalloc(dev, size, gfp);
If this is really necessary, please use devm_kmalloc
--
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