Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1502809
| From | Ulf Hansson <ulf.hansson@linaro.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] mmc: core: Check regulator pointer |
| Date | 2016-10-18 11:10 +0200 |
| Message-ID | <styzg-83y-3@gated-at.bofh.it> (permalink) |
| References | <styfT-7GN-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 18 October 2016 at 10:43, Maxime Ripard
<maxime.ripard@free-electrons.com> wrote:
> mmc_regulator_get_supply might silently fail if the regulators are not
> found, which is the right thing to do since both these regulators are
> optional.
>
> However, the drivers then have no way to know whether or not they should
> proceed and call mmc_regulator_set_ocr. And since this function doesn't
Host drivers should check "if (!IS_ERR(mmc->supply.vmmc))" before
invoking mmc_regulator_set_ocr(). I wasn't aware that some didn't.
My point is, that in some cases the regulator is optional, then a host
driver need to take other actions to power on/off the card. So, I am
wondering whether adding these checks in mmc_regulator_set_ocr() is a
bit unnecessary, as the host drivers are already checking the
IS_ERR().
> check for the validity of the regulator pointer, it leads to a null pointer
> dereference. Add such a check to make sure everything works fine.
>
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> ---
> drivers/mmc/core/core.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index 2553d903a82b..1d3ea5e1aa37 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -1474,6 +1474,12 @@ int mmc_regulator_set_ocr(struct mmc_host *mmc,
> int result = 0;
> int min_uV, max_uV;
>
> + if (!supply)
> + return -EINVAL;
> +
> + if (IS_ERR(supply))
> + return PTR_ERR(supply);
> +
> if (vdd_bit) {
> mmc_ocrbitnum_to_vdd(vdd_bit, &min_uV, &max_uV);
>
> --
> 2.9.3
>
Kind regards
Uffe
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] mmc: core: Check regulator pointer Maxime Ripard <maxime.ripard@free-electrons.com> - 2016-10-18 10:50 +0200
Re: [PATCH] mmc: core: Check regulator pointer Baolin Wang <baolin.wang@linaro.org> - 2016-10-18 11:00 +0200
Re: [PATCH] mmc: core: Check regulator pointer Ulf Hansson <ulf.hansson@linaro.org> - 2016-10-18 11:10 +0200
Re: [PATCH] mmc: core: Check regulator pointer Maxime Ripard <maxime.ripard@free-electrons.com> - 2016-10-18 11:50 +0200
Re: [PATCH] mmc: core: Check regulator pointer Ulf Hansson <ulf.hansson@linaro.org> - 2016-10-18 12:30 +0200
Re: [PATCH] mmc: core: Check regulator pointer Shawn Lin <shawn.lin@rock-chips.com> - 2016-10-18 14:30 +0200
csiph-web