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: <20160219085019.GA3410@x1>
Date:	Fri, 19 Feb 2016 08:50:19 +0000
From:	Lee Jones <lee.jones@...aro.org>
To:	Rhyland Klein <rklein@...dia.com>
Cc:	linux-kernel@...r.kernel.org,
	Laxman Dewangan <ldewangan@...dia.com>
Subject: Re: [PATCH] mfd: Fix MACRO for commonly declared MFD cell attributes

On Thu, 18 Feb 2016, Rhyland Klein wrote:

> MFD_ARRAY_SIZE() would not accurately return 0 if the passed
> parameter was NULL. Fix this so that num_resources will
> accurately be 0 in the case that _res is NULL.
> 
> cc: Lee Jones <lee.jones@...aro.org>
> cc: Laxman Dewangan <ldewangan@...dia.com>
> Signed-off-by: Rhyland Klein <rklein@...dia.com>
> ---
>  include/linux/mfd/core.h | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h
> index 1a5a87f3cd38..62136ccff1df 100644
> --- a/include/linux/mfd/core.h
> +++ b/include/linux/mfd/core.h
> @@ -18,11 +18,11 @@
>  
>  #define MFD_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
>  
> -#define MFD_CELL_ALL(_name, _res, _pdata, _id, _compat, _match)		\
> +#define MFD_CELL_ALL(_name, _nres, _res, _pdata, _id, _compat, _match)	\
>  	{								\
>  		.name = (_name),					\
>  		.resources = (_res),					\
> -		.num_resources = MFD_ARRAY_SIZE((_res)),		\
> +		.num_resources = (_nres),				\
>  		.platform_data = (_pdata),				\
>  		.pdata_size = MFD_ARRAY_SIZE((_pdata)), 		\
>  		.of_compatible = (_compat),				\
> @@ -31,16 +31,19 @@
>  	}
>  
>  #define OF_MFD_CELL(_name, _res, _pdata, _id, _compat)			\
> -		MFD_CELL_ALL(_name, _res, _pdata, _id, _compat, NULL)	\
> +		MFD_CELL_ALL(_name, MFD_ARRAY_SIZE((_res)), _res,	\
> +			_pdata, _id, _compat, NULL)			\

I'm confused.  Why would it be any different just by changing the call
site of MFD_ARRAY_SIZE?

And what about .platform_data?

How about this change instead?

diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h
index 1a5a87f..8440f42 100644
--- a/include/linux/mfd/core.h
+++ b/include/linux/mfd/core.h
@@ -16,7 +16,7 @@
 
 #include <linux/platform_device.h>
 
-#define MFD_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+#define MFD_ARRAY_SIZE(arr) (arr ? (sizeof(arr) / sizeof((arr)[0])) : 0)
 
 #define MFD_CELL_ALL(_name, _res, _pdata, _id, _compat, _match)                \
        {                                                               \

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ