Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1563890
| From | Subhash Jadavani <subhashj@codeaurora.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 1/4] phy: qcom-ufs: Don't kfree devres resource |
| Date | 2017-01-20 21:20 +0100 |
| Message-ID | <t1NPb-3oi-5@gated-at.bofh.it> (permalink) |
| References | <t1pWy-58h-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 2017-01-19 02:47, Bjorn Andersson wrote:
> Upon failing to acquire regulator supplies the qcom-ufs driver calls
> kfree() on the devm allocated memory used to store the name of the
> regulator, leading to devres corruption.
>
> Rather than switching to using the appropriate free function the patch
> acknowledge the fact that "name" is always a constant string and we
> don't actually need to create a local copy of it, but rather just
> reference the constant string.
>
> Cc: Subhash Jadavani <subhashj@codeaurora.org>
> Cc: Vivek Gautam <vivek.gautam@codeaurora.org>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---
> drivers/phy/phy-qcom-ufs.c | 9 +--------
> 1 file changed, 1 insertion(+), 8 deletions(-)
>
> diff --git a/drivers/phy/phy-qcom-ufs.c b/drivers/phy/phy-qcom-ufs.c
> index c69568b8543d..4d7f3c018223 100644
> --- a/drivers/phy/phy-qcom-ufs.c
> +++ b/drivers/phy/phy-qcom-ufs.c
> @@ -217,12 +217,7 @@ static int __ufs_qcom_phy_init_vreg(struct device
> *dev,
>
> char prop_name[MAX_PROP_NAME];
>
> - vreg->name = devm_kstrdup(dev, name, GFP_KERNEL);
> - if (!vreg->name) {
> - err = -ENOMEM;
> - goto out;
> - }
> -
> + vreg->name = name;
> vreg->reg = devm_regulator_get(dev, name);
> if (IS_ERR(vreg->reg)) {
> err = PTR_ERR(vreg->reg);
> @@ -265,8 +260,6 @@ static int __ufs_qcom_phy_init_vreg(struct device
> *dev,
> }
>
> out:
> - if (err)
> - kfree(vreg->name);
> return err;
> }
Looks good to me.
Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org>
--
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH 1/4] phy: qcom-ufs: Don't kfree devres resource Bjorn Andersson <bjorn.andersson@linaro.org> - 2017-01-19 19:50 +0100
[PATCH 2/4] phy: qcom-ufs: Correct usage of regulator_get() Bjorn Andersson <bjorn.andersson@linaro.org> - 2017-01-19 19:50 +0100
Re: [PATCH 2/4] phy: qcom-ufs: Correct usage of regulator_get() vivek.gautam@codeaurora.org - 2017-01-19 20:40 +0100
Re: [PATCH 2/4] phy: qcom-ufs: Correct usage of regulator_get() Subhash Jadavani <subhashj@codeaurora.org> - 2017-01-21 00:00 +0100
[PATCH 3/4] phy: qcom-ufs: Remove -always-on property Bjorn Andersson <bjorn.andersson@linaro.org> - 2017-01-19 19:50 +0100
Re: [PATCH 3/4] phy: qcom-ufs: Remove -always-on property Vivek Gautam <vivek.gautam@codeaurora.org> - 2017-01-19 20:50 +0100
Re: [PATCH 3/4] phy: qcom-ufs: Remove -always-on property Subhash Jadavani <subhashj@codeaurora.org> - 2017-01-21 00:00 +0100
Re: [PATCH 3/4] phy: qcom-ufs: Remove -always-on property Rob Herring <robh@kernel.org> - 2017-01-21 21:50 +0100
[PATCH 4/4] phy: qcom-ufs: Suppress extraneous logging Bjorn Andersson <bjorn.andersson@linaro.org> - 2017-01-19 19:50 +0100
Re: [PATCH 4/4] phy: qcom-ufs: Suppress extraneous logging Vivek Gautam <vivek.gautam@codeaurora.org> - 2017-01-19 21:10 +0100
Re: [PATCH 4/4] phy: qcom-ufs: Suppress extraneous logging Subhash Jadavani <subhashj@codeaurora.org> - 2017-01-21 00:00 +0100
Re: [PATCH 1/4] phy: qcom-ufs: Don't kfree devres resource Vivek Gautam <vivek.gautam@codeaurora.org> - 2017-01-19 21:10 +0100
Re: [PATCH 1/4] phy: qcom-ufs: Don't kfree devres resource Subhash Jadavani <subhashj@codeaurora.org> - 2017-01-20 21:20 +0100
csiph-web