linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Geliang Tang <geliangtang@163.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Raphaël Beamonte" <raphael.beamonte@gmail.com>,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	"Geliang Tang" <geliangtang@163.com>
Subject: Re: [PATCH 4/4] staging: rtl8192u: r8192U_core: use kmalloc_array instead of kmalloc
Date: Tue, 23 Feb 2016 08:55:04 +0800	[thread overview]
Message-ID: <20160223005504.GA1750@localhost.localdomain> (raw)
In-Reply-To: <20160208035509.GA13031@kroah.com>

On Sun, Feb 07, 2016 at 07:55:09PM -0800, Greg Kroah-Hartman wrote:
> On Sun, Nov 08, 2015 at 10:17:54PM +0800, Geliang Tang wrote:
> > Use kmalloc_array instead of kmalloc to allocate memory for an array.
> > 
> > Signed-off-by: Geliang Tang <geliangtang@163.com>
> > ---
> >  drivers/staging/rtl8192u/r8192U_core.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
> > index e06864f..07a1447 100644
> > --- a/drivers/staging/rtl8192u/r8192U_core.c
> > +++ b/drivers/staging/rtl8192u/r8192U_core.c
> > @@ -1725,8 +1725,8 @@ static short rtl8192_usb_initendpoints(struct net_device *dev)
> >  {
> >  	struct r8192_priv *priv = ieee80211_priv(dev);
> >  
> > -	priv->rx_urb = kmalloc(sizeof(struct urb *) * (MAX_RX_URB + 1),
> > -			       GFP_KERNEL);
> > +	priv->rx_urb = kmalloc_array(MAX_RX_URB + 1, sizeof(struct urb *),
> > +				     GFP_KERNEL);
> 
> I don't see the benefit here with this change, do you?

It is highly likely that there is a checkpatch warning "kmalloc with multiplies"
here. But the checkpatch script does not report this warning, I think it is
because MAX_RX_URB is a macro, and there is a '+1' after it. Therefore although
it passes,I think it still should be deemed as a warning. So to use kmalloc_array
here seems better.

Thanks.

- Geliang

  reply	other threads:[~2016-02-23  0:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-08 14:17 [PATCH 1/4] staging: comedi: use kmalloc_array instead of kmalloc Geliang Tang
2015-11-08 14:17 ` [PATCH 2/4] staging: rdma: " Geliang Tang
2015-11-08 14:17   ` [PATCH 3/4] staging: lustre: libcfs: " Geliang Tang
2015-11-08 14:17     ` [PATCH 4/4] staging: rtl8192u: r8192U_core: " Geliang Tang
2016-02-08  3:55       ` Greg Kroah-Hartman
2016-02-23  0:55         ` Geliang Tang [this message]
2016-02-23  1:10           ` Greg Kroah-Hartman
2015-11-09 13:49 ` [PATCH 1/4] staging: comedi: " Ian Abbott
2015-11-10 14:41   ` [PATCH v2] " Geliang Tang
2015-11-11 14:09     ` Ian Abbott

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=20160223005504.GA1750@localhost.localdomain \
    --to=geliangtang@163.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=raphael.beamonte@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).