diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-06-27 23:43:00 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-06-27 23:43:00 -0400 |
commit | 02184c60eba8491ea574cd17b8ba766c86d468f2 (patch) | |
tree | 168745f446cddfd411a2e247fefd1213a1d01da2 | |
parent | 18751e2eb51261059e51e1a7cf5aec2fd5429608 (diff) | |
parent | 362761299eea7dfc3a4870551de36e08758b9254 (diff) |
Merge tag 'for-v4.7-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply
Pull power supply fixes from Sebastian Reichel.
* tag 'for-v4.7-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply:
power_supply: tps65217-charger: Fix NULL deref during property export
power_supply: power_supply_read_temp only if use_cnt > 0
-rw-r--r-- | drivers/power/power_supply_core.c | 27 | ||||
-rw-r--r-- | drivers/power/tps65217_charger.c | 6 |
2 files changed, 21 insertions, 12 deletions
diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c index 456987c88baa..b13cd074c52a 100644 --- a/drivers/power/power_supply_core.c +++ b/drivers/power/power_supply_core.c | |||
@@ -565,11 +565,12 @@ static int power_supply_read_temp(struct thermal_zone_device *tzd, | |||
565 | 565 | ||
566 | WARN_ON(tzd == NULL); | 566 | WARN_ON(tzd == NULL); |
567 | psy = tzd->devdata; | 567 | psy = tzd->devdata; |
568 | ret = psy->desc->get_property(psy, POWER_SUPPLY_PROP_TEMP, &val); | 568 | ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_TEMP, &val); |
569 | if (ret) | ||
570 | return ret; | ||
569 | 571 | ||
570 | /* Convert tenths of degree Celsius to milli degree Celsius. */ | 572 | /* Convert tenths of degree Celsius to milli degree Celsius. */ |
571 | if (!ret) | 573 | *temp = val.intval * 100; |
572 | *temp = val.intval * 100; | ||
573 | 574 | ||
574 | return ret; | 575 | return ret; |
575 | } | 576 | } |
@@ -612,10 +613,12 @@ static int ps_get_max_charge_cntl_limit(struct thermal_cooling_device *tcd, | |||
612 | int ret; | 613 | int ret; |
613 | 614 | ||
614 | psy = tcd->devdata; | 615 | psy = tcd->devdata; |
615 | ret = psy->desc->get_property(psy, | 616 | ret = power_supply_get_property(psy, |
616 | POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX, &val); | 617 | POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX, &val); |
617 | if (!ret) | 618 | if (ret) |
618 | *state = val.intval; | 619 | return ret; |
620 | |||
621 | *state = val.intval; | ||
619 | 622 | ||
620 | return ret; | 623 | return ret; |
621 | } | 624 | } |
@@ -628,10 +631,12 @@ static int ps_get_cur_chrage_cntl_limit(struct thermal_cooling_device *tcd, | |||
628 | int ret; | 631 | int ret; |
629 | 632 | ||
630 | psy = tcd->devdata; | 633 | psy = tcd->devdata; |
631 | ret = psy->desc->get_property(psy, | 634 | ret = power_supply_get_property(psy, |
632 | POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT, &val); | 635 | POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT, &val); |
633 | if (!ret) | 636 | if (ret) |
634 | *state = val.intval; | 637 | return ret; |
638 | |||
639 | *state = val.intval; | ||
635 | 640 | ||
636 | return ret; | 641 | return ret; |
637 | } | 642 | } |
diff --git a/drivers/power/tps65217_charger.c b/drivers/power/tps65217_charger.c index d9f56730c735..73dfae41def8 100644 --- a/drivers/power/tps65217_charger.c +++ b/drivers/power/tps65217_charger.c | |||
@@ -197,6 +197,7 @@ static int tps65217_charger_probe(struct platform_device *pdev) | |||
197 | { | 197 | { |
198 | struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent); | 198 | struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent); |
199 | struct tps65217_charger *charger; | 199 | struct tps65217_charger *charger; |
200 | struct power_supply_config cfg = {}; | ||
200 | int ret; | 201 | int ret; |
201 | 202 | ||
202 | dev_dbg(&pdev->dev, "%s\n", __func__); | 203 | dev_dbg(&pdev->dev, "%s\n", __func__); |
@@ -208,9 +209,12 @@ static int tps65217_charger_probe(struct platform_device *pdev) | |||
208 | charger->tps = tps; | 209 | charger->tps = tps; |
209 | charger->dev = &pdev->dev; | 210 | charger->dev = &pdev->dev; |
210 | 211 | ||
212 | cfg.of_node = pdev->dev.of_node; | ||
213 | cfg.drv_data = charger; | ||
214 | |||
211 | charger->ac = devm_power_supply_register(&pdev->dev, | 215 | charger->ac = devm_power_supply_register(&pdev->dev, |
212 | &tps65217_charger_desc, | 216 | &tps65217_charger_desc, |
213 | NULL); | 217 | &cfg); |
214 | if (IS_ERR(charger->ac)) { | 218 | if (IS_ERR(charger->ac)) { |
215 | dev_err(&pdev->dev, "failed: power supply register\n"); | 219 | dev_err(&pdev->dev, "failed: power supply register\n"); |
216 | return PTR_ERR(charger->ac); | 220 | return PTR_ERR(charger->ac); |