Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

PM / devfreq: rk3399_dmc: Avoid static (reused) profile

This static struct can get reused if the device gets removed/reprobed,
and that causes use-after-free in its ->freq_table.

Let's just move the struct to our dynamic allocation.

Signed-off-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

authored by

Brian Norris and committed by
Chanwoo Choi
5d521a30 cb178a95

+9 -9
+9 -9
drivers/devfreq/rk3399_dmc.c
··· 38 38 struct rk3399_dmcfreq { 39 39 struct device *dev; 40 40 struct devfreq *devfreq; 41 + struct devfreq_dev_profile profile; 41 42 struct devfreq_simple_ondemand_data ondemand_data; 42 43 struct clk *dmc_clk; 43 44 struct devfreq_event_dev *edev; ··· 229 228 return 0; 230 229 } 231 230 232 - static struct devfreq_dev_profile rk3399_devfreq_dmc_profile = { 233 - .polling_ms = 200, 234 - .target = rk3399_dmcfreq_target, 235 - .get_dev_status = rk3399_dmcfreq_get_dev_status, 236 - .get_cur_freq = rk3399_dmcfreq_get_cur_freq, 237 - }; 238 - 239 231 static __maybe_unused int rk3399_dmcfreq_suspend(struct device *dev) 240 232 { 241 233 struct rk3399_dmcfreq *dmcfreq = dev_get_drvdata(dev); ··· 416 422 data->volt = dev_pm_opp_get_voltage(opp); 417 423 dev_pm_opp_put(opp); 418 424 419 - rk3399_devfreq_dmc_profile.initial_freq = data->rate; 425 + data->profile = (struct devfreq_dev_profile) { 426 + .polling_ms = 200, 427 + .target = rk3399_dmcfreq_target, 428 + .get_dev_status = rk3399_dmcfreq_get_dev_status, 429 + .get_cur_freq = rk3399_dmcfreq_get_cur_freq, 430 + .initial_freq = data->rate, 431 + }; 420 432 421 433 data->devfreq = devm_devfreq_add_device(dev, 422 - &rk3399_devfreq_dmc_profile, 434 + &data->profile, 423 435 DEVFREQ_GOV_SIMPLE_ONDEMAND, 424 436 &data->ondemand_data); 425 437 if (IS_ERR(data->devfreq)) {