From mboxrd@z Thu Jan 1 00:00:00 1970 From: Samuel Ortiz Date: Tue, 19 Oct 2010 10:50:54 +0000 Subject: Re: [PATCH] mfd/mc13xxx: don't open code kasprintf Message-Id: <20101019105053.GM2736@sortiz-mobl> List-Id: References: <1286731711-17865-1-git-send-email-segooon@gmail.com> <1286739586-32745-1-git-send-email-u.kleine-koenig@pengutronix.de> In-Reply-To: <1286739586-32745-1-git-send-email-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= Cc: Vasiliy Kulikov , kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Hi Uwe, On Sun, Oct 10, 2010 at 09:39:46PM +0200, Uwe Kleine-K=F6nig wrote: > This fixes an off by one error noticed by Vasiliy Kulikov en passant. >=20 > Signed-off-by: Uwe Kleine-K=F6nig > --- > drivers/mfd/mc13xxx-core.c | 7 +------ > 1 files changed, 1 insertions(+), 6 deletions(-) >=20 > 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 =3D mc13xxx_get_chipname(mc13xxx); > =20 > struct mfd_cell cell =3D { > @@ -695,11 +694,7 @@ static int mc13xxx_add_subdevice_pdata(struct mc13xx= x *mc13xxx, > .data_size =3D pdata_size, > }; > =20 > - /* there is no asnprintf in the kernel :-( */ > - if (snprintf(buf, sizeof(buf), format, name) > sizeof(buf)) > - return -E2BIG; > - > - cell.name =3D kmemdup(buf, strlen(buf) + 1, GFP_KERNEL); > + cell.name =3D kasprintf(GFP_KERNEL, format, name); I don't think you need to allocate a name pointer here. cell.name =3D 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; > =20 > --=20 > 1.7.2.3 >=20 --=20 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758277Ab0JSKvC (ORCPT ); Tue, 19 Oct 2010 06:51:02 -0400 Received: from mga02.intel.com ([134.134.136.20]:47750 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758160Ab0JSKvA (ORCPT ); Tue, 19 Oct 2010 06:51:00 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.57,349,1283756400"; d="scan'208";a="565365000" Date: Tue, 19 Oct 2010 12:50:54 +0200 From: Samuel Ortiz To: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= Cc: Vasiliy Kulikov , kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mfd/mc13xxx: don't open code kasprintf Message-ID: <20101019105053.GM2736@sortiz-mobl> References: <1286731711-17865-1-git-send-email-segooon@gmail.com> <1286739586-32745-1-git-send-email-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1286739586-32745-1-git-send-email-u.kleine-koenig@pengutronix.de> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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/