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, 16 Nov 2022 10:21:05 +0200
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Uwe Kleine-König 
        <u.kleine-koenig@...gutronix.de>
Cc:     Thierry Reding <thierry.reding@...il.com>,
        linux-pwm@...r.kernel.org, linux-kernel@...r.kernel.org,
        kernel@...gutronix.de
Subject: Re: [PATCH 4/4] pwm: Don't initialize list head before calling
 list_add()

On Tue, Nov 15, 2022 at 10:15:15PM +0100, Uwe Kleine-König wrote:
> list_add() just overwrites the members of the element to add (here:
> chip->list) without any checks, even in the DEBUG_LIST case. So save the
> effort to initialize the list.

This is good patch. I agree with it.

The cause of this code appearing either some older changes, or cargo cult
of the trick similar to when list_del_init() is used against a list node.
(FYI: that trick is useful to simplify the check if the node in question
 belongs to any list, by calling list_empty() against _node_ pointer)

The _add_ case with initialization makes no sense to me,

Reviewed-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>

> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
> ---
> Hello,
> 
> this patch I'm not sure about. A quick grep shows there are (only?) 40
> more code locations that call INIT_LIST_HEAD just before list_add().
> In my understanding INIT_LIST_HEAD is only to initialize lists, but
> chip->list is not a list, but the data needed to track chip as a list
> member.
> 
> Best regards
> Uwe
> 
>  drivers/pwm/core.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
> index b43b24bd3c9f..61bacd8d9b44 100644
> --- a/drivers/pwm/core.c
> +++ b/drivers/pwm/core.c
> @@ -299,7 +299,6 @@ int pwmchip_add(struct pwm_chip *chip)
>  		radix_tree_insert(&pwm_tree, pwm->pwm, pwm);
>  	}
>  
> -	INIT_LIST_HEAD(&chip->list);
>  	list_add(&chip->list, &pwm_chips);
>  
>  	mutex_unlock(&pwm_lock);
> -- 
> 2.38.1
> 

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ