mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@inria.fr>
To: Joe Perches <joe@perches.com>
Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	akpm@linux-foundation.org, natechancellor@gmail.com,
	geert+renesas@glider.be, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] lib/scatterlist: Avoid a double memset
Date: Sun, 20 Sep 2020 10:32:54 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.22.394.2009201032080.2966@hadrien> (raw)
In-Reply-To: <cd22db94ad43f788b158d6633a5b26b9c0aee5ba.camel@perches.com>



On Sun, 20 Sep 2020, Joe Perches wrote:

> On Sun, 2020-09-20 at 09:15 +0200, Christophe JAILLET wrote:
> > 'sgl' is zeroed a few lines below in 'sg_init_table()'. There is no need to
> > clear it twice.
> >
> > Remove the redundant initialization.
>
> I didn't look very thoroughly, but there are at least
> a few more of these with kcalloc and kzalloc like
>
> block/bsg-lib.c-        size_t sz = (sizeof(struct scatterlist) * req->nr_phys_segments);
> block/bsg-lib.c-
> block/bsg-lib.c-        BUG_ON(!req->nr_phys_segments);
> block/bsg-lib.c-
> block/bsg-lib.c-        buf->sg_list = kzalloc(sz, GFP_KERNEL);
> block/bsg-lib.c-        if (!buf->sg_list)
> block/bsg-lib.c-                return -ENOMEM;
> block/bsg-lib.c:        sg_init_table(buf->sg_list, req->nr_phys_segments);
> ---
> drivers/target/target_core_rd.c-		sg = kcalloc(sg_per_table + chain_entry, sizeof(*sg),
> drivers/target/target_core_rd.c-				GFP_KERNEL);
> drivers/target/target_core_rd.c-		if (!sg)
> drivers/target/target_core_rd.c-			return -ENOMEM;
> drivers/target/target_core_rd.c-
> drivers/target/target_core_rd.c:		sg_init_table(sg, sg_per_table + chain_entry);
> ---
> net/rds/rdma.c-		sg = kcalloc(nents, sizeof(*sg), GFP_KERNEL);
> net/rds/rdma.c-		if (!sg) {
> net/rds/rdma.c-			ret = -ENOMEM;
> net/rds/rdma.c-			goto out;
> net/rds/rdma.c-		}
> net/rds/rdma.c-		WARN_ON(!nents);
> net/rds/rdma.c:		sg_init_table(sg, nents);

I found 16 occurrences in the following files:

net/rds/rdma.c
drivers/infiniband/hw/efa/efa_verbs.c
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
drivers/misc/mic/scif/scif_nodeqp.c
block/bsg-lib.c
drivers/dma/sh/rcar-dmac.c
drivers/spi/spi-topcliff-pch.c
net/sunrpc/xprtrdma/frwr_ops.c
drivers/dma/imx-dma.c
drivers/pci/p2pdma.c
drivers/dma/sh/shdma-base.c
drivers/target/target_core_rd.c
drivers/media/common/saa7146/saa7146_core.c
drivers/tty/serial/pch_uart.c
drivers/net/wireless/intel/iwlwifi/fw/dbg.c

julia

  reply	other threads:[~2020-09-20  8:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-20  7:15 Christophe JAILLET
2020-09-20  7:28 ` Joe Perches
2020-09-20  8:32   ` Julia Lawall [this message]
2020-09-20  8:54     ` Christophe JAILLET

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=alpine.DEB.2.22.394.2009201032080.2966@hadrien \
    --to=julia.lawall@inria.fr \
    --cc=akpm@linux-foundation.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=geert+renesas@glider.be \
    --cc=joe@perches.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=natechancellor@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

all inboxes | Powered by JetHome®