Re: [PATCH v2 4/4] staging: ozwpan: use kmalloc_array over kmalloc with multiply

From: Tobias Klauser
Date: Tue Sep 09 2014 - 03:23:48 EST


On 2014-09-08 at 21:02:49 +0200, Adrian Nicoara <anicoara@xxxxxxxxxxxx> wrote:
> Cleanup checkpatch.pl warnings.

Please state which warning this is fixing. Same goes for patches 1-3.

> Signed-off-by: Adrian Nicoara <anicoara@xxxxxxxxxxxx>
> ---
>
> Somehow I missed the comment Tobias made on the line indentation. I fixed the
> patch, and added here as a reply - the previous patch should be ignored.
>
> drivers/staging/ozwpan/ozhcd.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c
> index ba2168f..e880452 100644
> --- a/drivers/staging/ozwpan/ozhcd.c
> +++ b/drivers/staging/ozwpan/ozhcd.c
> @@ -1315,8 +1315,8 @@ static int oz_build_endpoints_for_config(struct usb_hcd *hcd,
> if (num_iface) {
> struct oz_interface *iface;
>
> - iface = kmalloc(num_iface*sizeof(struct oz_interface),
> - mem_flags | __GFP_ZERO);
> + iface = kmalloc_array(num_iface, sizeof(struct oz_interface),
> + mem_flags | __GFP_ZERO);

This still isn't entirely correct. It should rather look like this:

iface = kmalloc_array(num_iface, sizeof(struct oz_interface),
mem_flags | __GFP_ZERO);

Assume a tab width of 8 (as per CodingStyle) and use spaces to get the
alignment right.

> if (!iface)
> return -ENOMEM;
> spin_lock_bh(&ozhcd->hcd_lock);
> --
> 2.0.1
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/