linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@inria.fr>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: kernel-janitors@vger.kernel.org,
	Jiri Slaby <jirislaby@kernel.org>,
	linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 01/14] pch_uart: drop double zeroing
Date: Sun, 20 Sep 2020 14:47:11 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.22.394.2009201443590.2966@hadrien> (raw)
In-Reply-To: <20200920121404.GA2830482@kroah.com>



On Sun, 20 Sep 2020, Greg Kroah-Hartman wrote:

> On Sun, Sep 20, 2020 at 01:26:13PM +0200, Julia Lawall wrote:
> > sg_init_table zeroes its first argument, so the allocation of that argument
> > doesn't have to.
> >
> > the semantic patch that makes this change is as follows:
> > (http://coccinelle.lip6.fr/)
> >
> > // <smpl>
> > @@
> > expression x,n,flags;
> > @@
> >
> > x =
> > - kcalloc
> > + kmalloc_array
> >   (n,sizeof(struct scatterlist),flags)
> > ...
> > sg_init_table(x,n)
> > // </smpl>
> >
> > Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
>
> It inits the first entry in the array, but what about all of the other
> ones?  Is that "safe" to have uninitialized data in them like your
> change causes to happen?

Sorry, I don't follow.  The complete code is:

        priv->sg_tx_p = kcalloc(num, sizeof(struct scatterlist), GFP_ATOMIC);
        if (!priv->sg_tx_p) {
		dev_err(priv->port.dev, "%s:kzalloc Failed\n", __func__);
                return 0;
	}

	sg_init_table(priv->sg_tx_p, num); /* Initialize SG table */

and the definition of sg_init_table is:

void sg_init_table(struct scatterlist *sgl, unsigned int nents)
{
	memset(sgl, 0, sizeof(*sgl) * nents);
	sg_init_marker(sgl, nents);
}

It looks to me like it zeroes all of the elements?  The same file does
contain a call:

sg_init_table(&priv->sg_rx, 1);

But that's not the one associated with the patch.

julia

  reply	other threads:[~2020-09-20 12:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-20 11:26 [PATCH 00/14] drop double zeroing Julia Lawall
2020-09-20 11:26 ` [PATCH 01/14] pch_uart: " Julia Lawall
2020-09-20 12:14   ` Greg Kroah-Hartman
2020-09-20 12:47     ` Julia Lawall [this message]
2020-09-27 12:11       ` Greg Kroah-Hartman
2020-09-21 16:58 ` [PATCH 00/14] " Mark Brown
2020-09-23 15:10   ` Rolf Reintjes
2020-09-23 15:16     ` Mark Brown
2020-10-13 22:42 ` Martin K. Petersen

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.2009201443590.2966@hadrien \
    --to=julia.lawall@inria.fr \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@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;
as well as URLs for NNTP newsgroup(s).