regulator: fixed: reject incompatible platform devices
PATCH 1/1 regulator: fixed: reject incompatible platform devices
The fixed regulator driver expects non-DT platform devices to provide their configuration through platform_data as a struct fixed_voltage_config.
An explicitly bound driver can bypass the normal platform device/driver matching and attach the fixed regulator driver to an unrelated platform device. This causes the driver's platform_data to be interpreted as a struct fixed_voltage_config even though it contains data for a different device.
Reject non-DT platform devices whose name does not match the fixed regulator driver before accessing their platform data.
--- drivers/regulator/fixed.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/regulator/fixed.c +4 -0
@@ -28,6 +28,7 @@#include <linux/regulator/of_regulator.h> #include <linux/regulator/machine.h> #include <linux/clk.h> +#include <linux/string.h> struct fixed_voltage_data {struct regulator_desc desc;
@@ -225,6 +226,9 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)enum gpiod_flags gflags;int ret; +if (!pdev->dev.of_node &&strcmp (pdev->name,"reg-fixed-voltage" )) +return -ENODEV ; + drvdata =devm_kzalloc (&pdev->dev,sizeof (struct fixed_voltage_data ),GFP_KERNEL );if (!drvdata)
Signature · 1 line
2.55.0
Mark Brown
maintainerQuoted 1 line · Chandradhar Kumar
regulator: fixed: reject incompatible platform devices
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-7.4
Thanks!
[1/1] regulator: fixed: reject incompatible platform devices
https://git.kernel.org/broonie/regulator/c/f7396c2dbbc1
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark