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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAPDyKFoUW53m_KMnVfFGNnz8DKQ2J=k10+XH=RdmDTtBgu_hkw@mail.gmail.com>
Date: Wed, 4 Sep 2024 15:06:43 +0200
From: Ulf Hansson <ulf.hansson@...aro.org>
To: Jens Wiklander <jens.wiklander@...aro.org>
Cc: linux-kernel@...r.kernel.org, Linus Walleij <linus.walleij@...aro.org>, 
	Arnd Bergmann <arnd@...db.de>, Greg Kroah-Hartman <gregkh@...uxfoundation.org>, 
	Dan Carpenter <dan.carpenter@...aro.org>
Subject: Re: [PATCH v2] rpmb: fix error path in rpmb_dev_register()

On Mon, 2 Sept 2024 at 12:58, Jens Wiklander <jens.wiklander@...aro.org> wrote:
>
> Until this patch was rpmb_dev_register() always freeing rdev in the
> error path. However, past device_register() it must not do that since
> the memory is now managed by the device even if it failed to register
> properly. So fix this by doing a device_put() before returning the error

/s/device_put/put_device

> code.
>
> Fixes the smatch warning:
>         drivers/misc/rpmb-core.c:204 rpmb_dev_register()
>         warn: freeing device managed memory (leak): 'rdev'
>
> Fixes: 1e9046e3a154 ("rpmb: add Replay Protected Memory Block (RPMB) subsystem")
> Reported-by: Dan Carpenter <dan.carpenter@...aro.org>
> Signed-off-by: Jens Wiklander <jens.wiklander@...aro.org>

With the above small amendment, applied to my mmc tree for next, thanks!

Kind regards
Uffe

> ---
> Changes in v2:
> - Remove the now unused err_id_remove label in rpmb_dev_register(),
>   reported by the kernel test robot
> ---
>  drivers/misc/rpmb-core.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/misc/rpmb-core.c b/drivers/misc/rpmb-core.c
> index c8888267c222..bc68cde1a8bf 100644
> --- a/drivers/misc/rpmb-core.c
> +++ b/drivers/misc/rpmb-core.c
> @@ -187,17 +187,15 @@ struct rpmb_dev *rpmb_dev_register(struct device *dev,
>         rdev->dev.parent = dev;
>
>         ret = device_register(&rdev->dev);
> -       if (ret)
> -               goto err_id_remove;
> +       if (ret) {
> +               put_device(&rdev->dev);
> +               return ERR_PTR(ret);
> +       }
>
>         dev_dbg(&rdev->dev, "registered device\n");
>
>         return rdev;
>
> -err_id_remove:
> -       mutex_lock(&rpmb_mutex);
> -       ida_simple_remove(&rpmb_ida, rdev->id);
> -       mutex_unlock(&rpmb_mutex);
>  err_free_dev_id:
>         kfree(rdev->descr.dev_id);
>  err_free_rdev:
> --
> 2.34.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ