lkml.org 
[lkml]   [2020]   [Aug]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH] ionic_lif: Use devm_kcalloc() in ionic_qcq_alloc()
From
Date
On Mon, 2020-08-10 at 02:38 +0000, Xu Wang wrote:
> A multiplication for the size determination of a memory allocation
> indicated that an array data structure should be processed.
> Thus use the corresponding function "devm_kcalloc".
[]
> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
[]
> @@ -412,7 +412,7 @@ static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type,
>
> new->flags = flags;
>
> - new->q.info = devm_kzalloc(dev, sizeof(*new->q.info) * num_descs,
> + new->q.info = devm_kcalloc(dev, num_descs, sizeof(*new->q.info),
> GFP_KERNEL);
> if (!new->q.info) {
> netdev_err(lif->netdev, "Cannot allocate queue info\n");

You could also remove these unnecessary allocation error messages.
There is an existing dump_stack() on allocation failure.

> @@ -462,7 +462,7 @@ static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type,
> new->intr.index = IONIC_INTR_INDEX_NOT_ASSIGNED;
> }
>
> - new->cq.info = devm_kzalloc(dev, sizeof(*new->cq.info) * num_descs,
> + new->cq.info = devm_kcalloc(dev, num_descs, sizeof(*new->cq.info),
> GFP_KERNEL);
> if (!new->cq.info) {
> netdev_err(lif->netdev, "Cannot allocate completion queue info\n");

\
 
 \ /
  Last update: 2020-08-10 05:21    [W:0.052 / U:3.096 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site