[PATCH 03/18] log: Add new category names to log_cat_name

Heinrich Schuchardt xypron.glpk at gmx.de
Tue Oct 6 22:45:16 CEST 2020


On 10/6/20 9:15 PM, Sean Anderson wrote:
> Without every category between LOGC_NONE and LOGC_COUNT present in
> log_cat_name, log_get_cat_by_name will dereference NULL pointers if it
> doesn't find a name early enough.
>
> Fixes: c3aed5db59 ("sandbox: spi: Add more logging")
> Fixes: a5c13b68e7 ("sandbox: log: Add a category for sandbox")
> Fixes: 9f407d4ef0 ("Add core support for a bloblist to convey data from SPL")
> Fixes: cce61fc428 ("dm: devres: Convert to use logging")
> Fixes: 7ca2850cbc ("dm: core: Add basic ACPI support")
>
> Signed-off-by: Sean Anderson <seanga2 at gmail.com>
> ---
>
>  common/log.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/common/log.c b/common/log.c
> index 3f6f4bdc2a..09e39b0eca 100644
> --- a/common/log.c
> +++ b/common/log.c
> @@ -21,6 +21,11 @@ static const char *log_cat_name[LOGC_COUNT - LOGC_NONE] = {

Please, make the array log_cat_name[] unsized and add a compile time
check like:

#if ARRAY_SIZE(log_cat_name) != LOGC_COUNT - LOGC_NONE
#error missing logging category name
#endif

Best regards

Heinrich

>  	"driver-model",
>  	"device-tree",
>  	"efi",
> +	"alloc",
> +	"sandbox",
> +	"bloblist",
> +	"devres",
> +	"acpi",
>  };
>
>  static const char *log_level_name[LOGL_COUNT] = {
>



More information about the U-Boot mailing list