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] [day] [month] [year] [list]
Date:   Thu, 25 Jul 2019 13:31:43 +0200
From:   Patrick Havelange <patrick.havelange@...ensium.com>
To:     Chuhong Yuan <hslester96@...il.com>
Cc:     William Breathitt Gray <vilhelm.gray@...il.com>,
        linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] counter/ftm-quaddec: Use device-managed registration API

Hello,

Comments inline

On Thu, Jul 25, 2019 at 10:55 AM Chuhong Yuan <hslester96@...il.com> wrote:
>
> Make use of devm_counter_register.
> Then we can remove redundant unregistration API
> usage to make code simpler.
>
> Signed-off-by: Chuhong Yuan <hslester96@...il.com>
> ---
>  drivers/counter/ftm-quaddec.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/counter/ftm-quaddec.c b/drivers/counter/ftm-quaddec.c
> index 68a9b7393457..bccbca8681b6 100644
> --- a/drivers/counter/ftm-quaddec.c
> +++ b/drivers/counter/ftm-quaddec.c
> @@ -317,7 +317,7 @@ static int ftm_quaddec_probe(struct platform_device *pdev)
>
>         ftm_quaddec_init(ftm);
>
> -       ret = counter_register(&ftm->counter);
> +       ret = devm_counter_register(&pdev->dev, &ftm->counter);
>         if (ret)
>                 ftm_quaddec_disable(ftm);
>
> @@ -328,8 +328,6 @@ static int ftm_quaddec_remove(struct platform_device *pdev)
>  {
>         struct ftm_quaddec *ftm = platform_get_drvdata(pdev);
>
> -       counter_unregister(&ftm->counter);
> -

The orders of (de)initialization should be kept symmetrical.
In this case, now that counter_unregister() will be called via devm,
it will be executed after ftm_quaddec_remove()

This introduces a race condition where the ftm-quaddec is disabled but
the counter entry itself is not.

Somebody else (William?) should confirm this.


>         ftm_quaddec_disable(ftm);
>
>         return 0;
> --
> 2.20.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ