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:	Tue, 6 Nov 2012 11:12:56 +0000
From:	Charles Keepax <ckeepax@...nsource.wolfsonmicro.com>
To:	Laxman Dewangan <ldewangan@...dia.com>
Cc:	broonie@...nsource.wolfsonmicro.com, lrg@...com,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] regulator: core: avoid memory access after freeing it

On Tue, Nov 06, 2012 at 04:04:09PM +0530, Laxman Dewangan wrote:
> When regulator_register() failed due to non availability of
>  	mutex_unlock(&regulator_list_mutex);
...
>  }
>  EXPORT_SYMBOL_GPL(regulator_put);
> @@ -3453,11 +3460,10 @@ scrub:
>  		gpio_free(rdev->ena_gpio);
>  	kfree(rdev->constraints);
>  wash:
> +	if (rdev->supply)
> +		__regulator_put_locked(rdev->supply);
>  	device_unregister(&rdev->dev);
> -
>  	mutex_unlock(&regulator_list_mutex);
> -	if (rdev->supply)
> -		regulator_put(rdev->supply);
>  
>  	/* device core frees rdev */
>  	rdev = ERR_PTR(ret);

Here would it not make sense to go slightly further and basically
revert my original change. This feels sensible as it keeps it at
only one location where the mutex is unlocked and removes the
second exit point I added. This would effectively make the code
look like:

scrub:
	if (rdev->supply)
		__regulator_put_locked(rdev->supply);
	if (rdev->ena_gpio)
		gpio_free(rdev->ena_gpio);
	kfree(rdev->constraints);
	device_unregister(&rdev->dev);
	/* device core frees rdev */
	rdev = ERR_PTR(ret);
	goto out;

Otherwise the change looks great to me.

> -- 
> 1.7.1.1
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ