lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 3 Aug 2022 11:40:41 +0200
From:   Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
To:     Sherry Sun <sherry.sun@....com>
Cc:     Ahmad Fatoum <a.fatoum@...gutronix.de>,
        "gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
        "jirislaby@...nel.org" <jirislaby@...nel.org>,
        "shawnguo@...nel.org" <shawnguo@...nel.org>,
        "s.hauer@...gutronix.de" <s.hauer@...gutronix.de>,
        "kernel@...gutronix.de" <kernel@...gutronix.de>,
        "festevam@...il.com" <festevam@...il.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-serial@...r.kernel.org" <linux-serial@...r.kernel.org>,
        dl-linux-imx <linux-imx@....com>
Subject: Re: [PATCH] tty: serial: imx: initialize
 peripheral_config/peripheral_size for sdma config

On Wed, Aug 03, 2022 at 09:15:58AM +0000, Sherry Sun wrote:
> > On 03.08.22 08:57, Sherry Sun wrote:
> > > Since commit 824a0a02cd74 ("dmaengine: imx-sdma: Add multi fifo
> > > support") adds the use of
> > > dma_slave_config->peripheral_config/peripheral_size to sdma driver,
> > > the client drivers like uart need to initialize the
> > > peripheral_config/peripheral_size for sdma, otherwise, the random
> > > value of local variable slave_config may cause unexpected
> > peripheral_config and make sdma mess up.
> > >
> > 
> > If this a fix, please add a Fixes: tag. I am not sure it is though, see below.
> 
> Hi Ahmad, thanks for the comments.
> I don't think this patch is a fix for a specific commit, so we don't need the Fixes tag.
> 
> > 
> > > Signed-off-by: Sherry Sun <sherry.sun@....com>
> > > ---
> > >  drivers/tty/serial/imx.c | 4 ++++
> > >  1 file changed, 4 insertions(+)
> > >
> > > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index
> > > 522445a8f666..bb8c2a712e94 100644
> > > --- a/drivers/tty/serial/imx.c
> > > +++ b/drivers/tty/serial/imx.c
> > > @@ -1320,6 +1320,8 @@ static int imx_uart_dma_init(struct imx_port
> > > *sport)
> > 
> > This function starts with
> > 
> > struct dma_slave_config slave_config = {};
> > 
> > >  	slave_config.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
> > >  	/* one byte less than the watermark level to enable the aging timer
> > */
> > >  	slave_config.src_maxburst = RXTL_DMA - 1;
> > > +	slave_config.peripheral_config = NULL;
> > > +	slave_config.peripheral_size = 0;
> > 
> > So these are already zero-initialized.
> 
> I am not sure actually, I think initialize a struct with {} cannot
> guarantee that all members are initialized to 0, it may depend on the
> compiler.

I'm sure and even reverified in my C book[1].

	struct mystruct variable = {};

results in all components being initialized to their default initial
value (which is 0 for numbers and NULL for pointers). This works for
automatic variables since "Standard C" which should cover everthing that
is capable to compile today's kernel.

Best regards
Uwe

[1] C - A Reference Manual, 978-0130895929

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ