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: <20190320162924.GA3622@lahna.fi.intel.com>
Date:   Wed, 20 Mar 2019 18:29:24 +0200
From:   Mika Westerberg <mika.westerberg@...ux.intel.com>
To:     Aditya Pakki <pakki001@....edu>
Cc:     kjlu@....edu, Andreas Noever <andreas.noever@...il.com>,
        Michael Jamet <michael.jamet@...el.com>,
        Yehezkel Bernat <YehezkelShB@...il.com>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] thunderbolt: Fix to check return value of
 ida_simple_get

On Wed, Mar 20, 2019 at 11:24:45AM -0500, Aditya Pakki wrote:
> In enumerate_services, ida_simple_get on failure can return an error and
> leaks memory during device_register failure. The patch ensures that
> the dev_set_name is set on non failure cases, and releases memory in
> case of failure.
> 
> Signed-off-by: Aditya Pakki <pakki001@....edu>
> 
> ---
> v1: Missed cleanup of svc in case of allocation failure and
> device_register failure.
> ---
>  drivers/thunderbolt/xdomain.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c
> index e27dd8beb94b..eb08275185bf 100644
> --- a/drivers/thunderbolt/xdomain.c
> +++ b/drivers/thunderbolt/xdomain.c
> @@ -740,6 +740,7 @@ static void enumerate_services(struct tb_xdomain *xd)
>  	struct tb_service *svc;
>  	struct tb_property *p;
>  	struct device *dev;
> +	int id;
>  
>  	/*
>  	 * First remove all services that are not available anymore in
> @@ -768,7 +769,12 @@ static void enumerate_services(struct tb_xdomain *xd)
>  			break;
>  		}
>  
> -		svc->id = ida_simple_get(&xd->service_ids, 0, 0, GFP_KERNEL);
> +		id = ida_simple_get(&xd->service_ids, 0, 0, GFP_KERNEL);
> +		if (id < 0) {
> +			kfree(svc);
> +			break;
> +		}
> +		svc->id = id;
>  		svc->dev.bus = &tb_bus_type;
>  		svc->dev.type = &tb_service_type;
>  		svc->dev.parent = &xd->dev;
> @@ -776,6 +782,7 @@ static void enumerate_services(struct tb_xdomain *xd)
>  
>  		if (device_register(&svc->dev)) {
>  			put_device(&svc->dev);
> +			kfree(svc);

You can't do this after device_register() is called. The put_device()
above is sufficient.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ