mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-12 03:26:26 +00:00
regulator: fix use after free issue
This is caused by dereferencing 'rdev' after put_device() in the _regulator_get()/_regulator_put() functions. This patch just moves the put_device() down a bit to avoid the issue. Signed-off-by: Wen Yang <wenyang@linux.alibaba.com> Cc: Liam Girdwood <lgirdwood@gmail.com> Cc: Mark Brown <broonie@kernel.org> Cc: linux-kernel@vger.kernel.org Link: https://lore.kernel.org/r/20191124145835.25999-1-wenyang@linux.alibaba.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
c15d5a6458
commit
4affd79a12
1 changed files with 2 additions and 2 deletions
|
@ -1937,8 +1937,8 @@ struct regulator *_regulator_get(struct device *dev, const char *id,
|
||||||
regulator = create_regulator(rdev, dev, id);
|
regulator = create_regulator(rdev, dev, id);
|
||||||
if (regulator == NULL) {
|
if (regulator == NULL) {
|
||||||
regulator = ERR_PTR(-ENOMEM);
|
regulator = ERR_PTR(-ENOMEM);
|
||||||
put_device(&rdev->dev);
|
|
||||||
module_put(rdev->owner);
|
module_put(rdev->owner);
|
||||||
|
put_device(&rdev->dev);
|
||||||
return regulator;
|
return regulator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2059,13 +2059,13 @@ static void _regulator_put(struct regulator *regulator)
|
||||||
|
|
||||||
rdev->open_count--;
|
rdev->open_count--;
|
||||||
rdev->exclusive = 0;
|
rdev->exclusive = 0;
|
||||||
put_device(&rdev->dev);
|
|
||||||
regulator_unlock(rdev);
|
regulator_unlock(rdev);
|
||||||
|
|
||||||
kfree_const(regulator->supply_name);
|
kfree_const(regulator->supply_name);
|
||||||
kfree(regulator);
|
kfree(regulator);
|
||||||
|
|
||||||
module_put(rdev->owner);
|
module_put(rdev->owner);
|
||||||
|
put_device(&rdev->dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue