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: <Pine.LNX.4.44L0.1506081111050.1574-100000@iolanthe.rowland.org>
Date:	Mon, 8 Jun 2015 11:17:13 -0400 (EDT)
From:	Alan Stern <stern@...land.harvard.edu>
To:	Vivek Gautam <gautam.vivek@...sung.com>
cc:	linux-usb@...r.kernel.org, <linux-samsung-soc@...r.kernel.org>,
	<gregkh@...uxfoundation.org>, <devicetree@...r.kernel.org>,
	<linux-kernel@...r.kernel.org>, Jingoo Han <jg1.han@...sung.com>,
	Krzysztof Kozlowski <k.kozlowski@...sung.com>
Subject: Re: [PATCH v4 1/2] usb: ehci-exynos: Make provision for vdd regulators

On Mon, 8 Jun 2015, Vivek Gautam wrote:

> Facilitate getting required 3.3V and 1.0V VDD supply for
> EHCI controller on Exynos.
> 
> For example, patches for regulators' nodes:
> c8c253f ARM: dts: Add regulator entries to smdk5420
> 275dcd2 ARM: dts: add max77686 pmic node for smdk5250,
> enable only minimum number of regulators on smdk5250.
> 
> So ensuring now that the controller driver requests the necessary
> VDD regulators (if available, unless there are direct VDD rails),
> and enable them so as to make them working on exynos systems.
> 
> Signed-off-by: Vivek Gautam <gautam.vivek@...sung.com>

Something about this looks a little fishy...

> @@ -170,7 +173,27 @@ static int exynos_ehci_probe(struct platform_device *pdev)
>  
>  	err = exynos_ehci_get_phy(&pdev->dev, exynos_ehci);
>  	if (err)
> -		goto fail_clk;
> +		goto fail_regulator1;
> +
> +	exynos_ehci->vdd33 = devm_regulator_get_optional(&pdev->dev, "vdd33");

Just before this region of code, there is:

	if (of_device_is_compatible(pdev->dev.of_node,
					"samsung,exynos5440-ehci"))
		goto skip_phy;

If that "goto" is taken, exynos_ehci->vdd33 and ->vdd10 will be NULL, 
not an ERR_PTR code.

> +	if (!IS_ERR(exynos_ehci->vdd33)) {
> +		err = regulator_enable(exynos_ehci->vdd33);
> +		if (err) {
> +			dev_err(&pdev->dev,
> +				"Failed to enable 3.3V Vdd supply\n");
> +			goto fail_regulator1;
> +		}
> +	}
> +
> +	exynos_ehci->vdd10 = devm_regulator_get_optional(&pdev->dev, "vdd10");
> +	if (!IS_ERR(exynos_ehci->vdd10)) {
> +		err = regulator_enable(exynos_ehci->vdd10);
> +		if (err) {
> +			dev_err(&pdev->dev,
> +				"Failed to enable 1.0V Vdd supply\n");
> +			goto fail_regulator2;
> +		}
> +	}
>  
>  skip_phy:
>  
> @@ -231,6 +254,12 @@ fail_add_hcd:
>  fail_io:
>  	clk_disable_unprepare(exynos_ehci->clk);
>  fail_clk:
> +	if (!IS_ERR(exynos_ehci->vdd10))
> +		regulator_disable(exynos_ehci->vdd10);
> +fail_regulator2:
> +	if (!IS_ERR(exynos_ehci->vdd33))
> +		regulator_disable(exynos_ehci->vdd33);

Which means these regulator_disable() calls will crash when they 
dereference a NULL pointer.

I think it would be simpler in the end to let a NULL pointer mean the 
regulator isn't present.  If devm_regulator_get_optional() returns an 
error, convert it to NULL (or don't do the assignment to 
exynos_ehci->vdd?? in the first place).

The same criticism applies to the other patch in this series.

Alan Stern

--
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