From: Samuel Ortiz <sameo@linux.intel.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Vasiliy Kulikov <segooon@gmail.com>,
kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mfd/mc13xxx: don't open code kasprintf
Date: Tue, 19 Oct 2010 10:50:54 +0000 [thread overview]
Message-ID: <20101019105053.GM2736@sortiz-mobl> (raw)
In-Reply-To: <1286739586-32745-1-git-send-email-u.kleine-koenig@pengutronix.de>
Hi Uwe,
On Sun, Oct 10, 2010 at 09:39:46PM +0200, Uwe Kleine-König wrote:
> This fixes an off by one error noticed by Vasiliy Kulikov en passant.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
> drivers/mfd/mc13xxx-core.c | 7 +------
> 1 files changed, 1 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/mfd/mc13xxx-core.c b/drivers/mfd/mc13xxx-core.c
> index 93258ad..b763b8c 100644
> --- a/drivers/mfd/mc13xxx-core.c
> +++ b/drivers/mfd/mc13xxx-core.c
> @@ -687,7 +687,6 @@ EXPORT_SYMBOL_GPL(mc13783_adc_do_conversion);
> static int mc13xxx_add_subdevice_pdata(struct mc13xxx *mc13xxx,
> const char *format, void *pdata, size_t pdata_size)
> {
> - char buf[30];
> const char *name = mc13xxx_get_chipname(mc13xxx);
>
> struct mfd_cell cell = {
> @@ -695,11 +694,7 @@ static int mc13xxx_add_subdevice_pdata(struct mc13xxx *mc13xxx,
> .data_size = pdata_size,
> };
>
> - /* there is no asnprintf in the kernel :-( */
> - if (snprintf(buf, sizeof(buf), format, name) > sizeof(buf))
> - return -E2BIG;
> -
> - cell.name = kmemdup(buf, strlen(buf) + 1, GFP_KERNEL);
> + cell.name = kasprintf(GFP_KERNEL, format, name);
I don't think you need to allocate a name pointer here.
cell.name = mc13xxx_get_chipname(mc13xxx); should be enough as
platform_device_alloc() will memcpy it into an allocated buffer.
Cheers,
Samuel.
> if (!cell.name)
> return -ENOMEM;
>
> --
> 1.7.2.3
>
--
Intel Open Source Technology Centre
http://oss.intel.com/
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: Samuel Ortiz <sameo@linux.intel.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Vasiliy Kulikov <segooon@gmail.com>,
kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mfd/mc13xxx: don't open code kasprintf
Date: Tue, 19 Oct 2010 12:50:54 +0200 [thread overview]
Message-ID: <20101019105053.GM2736@sortiz-mobl> (raw)
In-Reply-To: <1286739586-32745-1-git-send-email-u.kleine-koenig@pengutronix.de>
Hi Uwe,
On Sun, Oct 10, 2010 at 09:39:46PM +0200, Uwe Kleine-König wrote:
> This fixes an off by one error noticed by Vasiliy Kulikov en passant.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
> drivers/mfd/mc13xxx-core.c | 7 +------
> 1 files changed, 1 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/mfd/mc13xxx-core.c b/drivers/mfd/mc13xxx-core.c
> index 93258ad..b763b8c 100644
> --- a/drivers/mfd/mc13xxx-core.c
> +++ b/drivers/mfd/mc13xxx-core.c
> @@ -687,7 +687,6 @@ EXPORT_SYMBOL_GPL(mc13783_adc_do_conversion);
> static int mc13xxx_add_subdevice_pdata(struct mc13xxx *mc13xxx,
> const char *format, void *pdata, size_t pdata_size)
> {
> - char buf[30];
> const char *name = mc13xxx_get_chipname(mc13xxx);
>
> struct mfd_cell cell = {
> @@ -695,11 +694,7 @@ static int mc13xxx_add_subdevice_pdata(struct mc13xxx *mc13xxx,
> .data_size = pdata_size,
> };
>
> - /* there is no asnprintf in the kernel :-( */
> - if (snprintf(buf, sizeof(buf), format, name) > sizeof(buf))
> - return -E2BIG;
> -
> - cell.name = kmemdup(buf, strlen(buf) + 1, GFP_KERNEL);
> + cell.name = kasprintf(GFP_KERNEL, format, name);
I don't think you need to allocate a name pointer here.
cell.name = mc13xxx_get_chipname(mc13xxx); should be enough as
platform_device_alloc() will memcpy it into an allocated buffer.
Cheers,
Samuel.
> if (!cell.name)
> return -ENOMEM;
>
> --
> 1.7.2.3
>
--
Intel Open Source Technology Centre
http://oss.intel.com/
next prev parent reply other threads:[~2010-10-19 10:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-10 17:28 [PATCH] drivers: mfd: fix off by one error Vasiliy Kulikov
2010-10-10 17:28 ` Vasiliy Kulikov
2010-10-10 19:39 ` [PATCH] mfd/mc13xxx: don't open code kasprintf
2010-10-10 19:39 ` Uwe Kleine-König
2010-10-15 13:18 `
2010-10-15 13:18 ` Uwe Kleine-König
2010-10-19 10:50 ` Samuel Ortiz [this message]
2010-10-19 10:50 ` Samuel Ortiz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101019105053.GM2736@sortiz-mobl \
--to=sameo@linux.intel.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=segooon@gmail.com \
--cc=u.kleine-koenig@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.