From: Ian Abbott <abbotti@mev.co.uk>
To: Geliang Tang <geliangtang@163.com>,
H Hartley Sweeten <hsweeten@visionengravers.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] staging: comedi: use kmalloc_array instead of kmalloc
Date: Wed, 11 Nov 2015 14:09:23 +0000 [thread overview]
Message-ID: <56434C13.3070808@mev.co.uk> (raw)
In-Reply-To: <f8a6ba45a6cb1f4fc5ed2197bbeadc59a8aa5999.1447165847.git.geliangtang@163.com>
On 10/11/2015 14:41, Geliang Tang wrote:
> Use kmalloc_array instead of kmalloc to allocate memory for an array.
>
> Signed-off-by: Geliang Tang <geliangtang@163.com>
>
> ---
> Changes in v2:
> - preserve the existing whitespace style.
> ---
> drivers/staging/comedi/drivers/amplc_pci224.c | 11 +++++++----
> drivers/staging/comedi/drivers/ni_670x.c | 5 +++--
> 2 files changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c
> index b2f7679..cac011f 100644
> --- a/drivers/staging/comedi/drivers/amplc_pci224.c
> +++ b/drivers/staging/comedi/drivers/amplc_pci224.c
> @@ -1022,14 +1022,17 @@ pci224_auto_attach(struct comedi_device *dev, unsigned long context_model)
> irq = pci_dev->irq;
>
> /* Allocate buffer to hold values for AO channel scan. */
> - devpriv->ao_scan_vals = kmalloc(sizeof(devpriv->ao_scan_vals[0]) *
> - board->ao_chans, GFP_KERNEL);
> + devpriv->ao_scan_vals = kmalloc_array(board->ao_chans,
> + sizeof(devpriv->ao_scan_vals[0]),
> + GFP_KERNEL);
> if (!devpriv->ao_scan_vals)
> return -ENOMEM;
>
> /* Allocate buffer to hold AO channel scan order. */
> - devpriv->ao_scan_order = kmalloc(sizeof(devpriv->ao_scan_order[0]) *
> - board->ao_chans, GFP_KERNEL);
> + devpriv->ao_scan_order =
> + kmalloc_array(board->ao_chans,
> + sizeof(devpriv->ao_scan_order[0]),
> + GFP_KERNEL);
> if (!devpriv->ao_scan_order)
> return -ENOMEM;
>
> diff --git a/drivers/staging/comedi/drivers/ni_670x.c b/drivers/staging/comedi/drivers/ni_670x.c
> index f4c580f..3e7271880 100644
> --- a/drivers/staging/comedi/drivers/ni_670x.c
> +++ b/drivers/staging/comedi/drivers/ni_670x.c
> @@ -214,8 +214,9 @@ static int ni_670x_auto_attach(struct comedi_device *dev,
> if (s->n_chan == 32) {
> const struct comedi_lrange **range_table_list;
>
> - range_table_list = kmalloc(sizeof(struct comedi_lrange *) * 32,
> - GFP_KERNEL);
> + range_table_list = kmalloc_array(32,
> + sizeof(struct comedi_lrange *),
> + GFP_KERNEL);
> if (!range_table_list)
> return -ENOMEM;
> s->range_table_list = range_table_list;
>
Seems fine!
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
--
-=( Ian Abbott @ MEV Ltd. E-mail: <abbotti@mev.co.uk> )=-
-=( Web: http://www.mev.co.uk/ )=-
prev parent reply other threads:[~2015-11-11 14:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-08 14:17 [PATCH 1/4] " 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
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 [this message]
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=56434C13.3070808@mev.co.uk \
--to=abbotti@mev.co.uk \
--cc=devel@driverdev.osuosl.org \
--cc=geliangtang@163.com \
--cc=gregkh@linuxfoundation.org \
--cc=hsweeten@visionengravers.com \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®