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]
Message-ID: <CAK7LNAROhYMYx2_rcJG_vrirJz+9Cy2r+PzDr1HggQJE2Zsesg@mail.gmail.com>
Date:   Fri, 20 Oct 2017 22:47:16 +0900
From:   Masahiro Yamada <yamada.masahiro@...ionext.com>
To:     Greg KH <gregkh@...uxfoundation.org>
Cc:     Srinivas Kandagatla <srinivas.kandagatla@...aro.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 01/12] nvmem: imx-iim: use stack for nvmem_config instead
 of malloc'ing it

Hi Greg,

2017-10-20 22:32 GMT+09:00 Greg KH <gregkh@...uxfoundation.org>:
> On Mon, Oct 09, 2017 at 03:26:30PM +0200, srinivas.kandagatla@...aro.org wrote:
>> From: Masahiro Yamada <yamada.masahiro@...ionext.com>
>>
>> nvmem_register() copies all the members of nvmem_config to
>> nvmem_device.  So, nvmem_config is one-time use data during
>> probing.  There is no point to keep it until the driver detach.
>> Using stack should be no problem because nvmem_config is pretty
>> small.
>>
>> Signed-off-by: Masahiro Yamada <yamada.masahiro@...ionext.com>
>> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
>> ---
>>  drivers/nvmem/imx-iim.c | 27 ++++++++++++---------------
>>  1 file changed, 12 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/nvmem/imx-iim.c b/drivers/nvmem/imx-iim.c
>> index 52ff65e0673f..a5992602709a 100644
>> --- a/drivers/nvmem/imx-iim.c
>> +++ b/drivers/nvmem/imx-iim.c
>> @@ -34,7 +34,6 @@ struct imx_iim_drvdata {
>>  struct iim_priv {
>>       void __iomem *base;
>>       struct clk *clk;
>> -     struct nvmem_config nvmem;
>>  };
>>
>>  static int imx_iim_read(void *context, unsigned int offset,
>> @@ -108,7 +107,7 @@ static int imx_iim_probe(struct platform_device *pdev)
>>       struct resource *res;
>>       struct iim_priv *iim;
>>       struct nvmem_device *nvmem;
>> -     struct nvmem_config *cfg;
>> +     struct nvmem_config cfg = {};
>
> You do realize you are now not zeroing out this structure, and have to
> explicitly initialize all of the fields, right?

Why?

I am surely zeroing out the structure.

Did you miss "= {};" in my code?



> What is the real problem with doing a dynamic allocation for this?
> Putting structures on the stack is a "bad idea" for all of the obvious
> reasons (small stack in the kernel, initialized data, lower layers
> expect it to be dma-able, etc.)


Why is this a problem?

Did you really understand this patch?

 - This structure is very small.
   struct uart_8250_port is five times bigger
   and it is allocated in the stack and it is fine.

 - All data are initialized.

 - Why DMA?
   Please do not exaggerate things by introducing unrelated topic.



-- 
Best Regards
Masahiro Yamada

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ