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: <20210531101725.GB30390@gofer.mess.org>
Date:   Mon, 31 May 2021 11:17:25 +0100
From:   Sean Young <sean@...s.org>
To:     Christophe JAILLET <christophe.jaillet@...adoo.fr>
Cc:     Yasunari.Takiguchi@...y.com, mchehab@...nel.org,
        narmstrong@...libre.com, linux-media@...r.kernel.org,
        linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: Re: [PATCH 1/2] media: cxd2880-spi: Fix an error handling path

On Fri, May 21, 2021 at 02:18:14PM +0200, Christophe JAILLET wrote:
> If an error occurs after a successful 'regulator_enable()' call,
> 'regulator_disable()' must be called.
> 
> Fix the error handling path of the probe accordingly.
> 
> Fixes: cb496cd472af ("media: cxd2880-spi: Add optional vcc regulator")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
> ---
>  drivers/media/spi/cxd2880-spi.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/spi/cxd2880-spi.c b/drivers/media/spi/cxd2880-spi.c
> index 931ec0727cd3..df1335e7061c 100644
> --- a/drivers/media/spi/cxd2880-spi.c
> +++ b/drivers/media/spi/cxd2880-spi.c
> @@ -524,13 +524,13 @@ cxd2880_spi_probe(struct spi_device *spi)
>  	if (IS_ERR(dvb_spi->vcc_supply)) {
>  		if (PTR_ERR(dvb_spi->vcc_supply) == -EPROBE_DEFER) {
>  			ret = -EPROBE_DEFER;
> -			goto fail_adapter;
> +			goto fail_regulator;
>  		}
>  		dvb_spi->vcc_supply = NULL;

vcc_supply is set to null in this path.

>  	} else {
>  		ret = regulator_enable(dvb_spi->vcc_supply);
>  		if (ret)
> -			goto fail_adapter;
> +			goto fail_regulator;
>  	}
>  
>  	dvb_spi->spi = spi;
> @@ -618,6 +618,9 @@ cxd2880_spi_probe(struct spi_device *spi)
>  fail_attach:
>  	dvb_unregister_adapter(&dvb_spi->adapter);
>  fail_adapter:
> +	if (!IS_ERR(dvb_spi->vcc_supply))
> +		regulator_disable(dvb_spi->vcc_supply);

IS_ERR(NULL) -> false
regulator_disable will dereference a null pointer.


Sean

> +fail_regulator:
>  	kfree(dvb_spi);
>  	return ret;
>  }
> -- 
> 2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ