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] [day] [month] [year] [list]
Message-ID: <CAFp+6iGqR-RCukOZ1AV22GXxOmNkhReLWCie-zS1tP_cC1bJ6A@mail.gmail.com>
Date:	Fri, 12 Jun 2015 00:13:26 +0530
From:	Vivek Gautam <gautamvivek1987@...il.com>
To:	Alan Stern <stern@...land.harvard.edu>
Cc:	Vivek Gautam <gautam.vivek@...sung.com>,
	Linux USB Mailing List <linux-usb@...r.kernel.org>,
	"linux-samsung-soc@...r.kernel.org" 
	<linux-samsung-soc@...r.kernel.org>,
	Greg KH <gregkh@...uxfoundation.org>,
	"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
	"linux-kernel@...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

Hi,


On Mon, Jun 8, 2015 at 8:47 PM, Alan Stern <stern@...land.harvard.edu> wrote:
> 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...

Sorry, i didn't get you.
This patch was initially posted by me sometime back.

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

Right. This will hit NULL pointer dereferencing later in the 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;
>> +             }
>> +     }

May be we can have something like this:

     if (IS_ERR(exynos_ehci->vdd33)) {
             exynos_ehci->vdd33 = NULL;
     } else {
             err = regulator_enable(exynos_ehci->vdd33);
             if (err) {
                     dev_err(&pdev->dev,
                             "Failed to enable 3.3V Vdd supply\n");
                     goto fail_regulator1;
             }
     }

and later in the code check for NULL pointer before enabling the regulator.

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

Sure, i will amend both the patches.

Thanks !

-- 
Best Regards
Vivek Gautam
Samsung R&D Institute, Bangalore
India
--
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