Skip to content

Commit

Permalink
Merge tag 'for-v4.7-rc' of git://git.kernel.org/pub/scm/linux/kernel/…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
Linus Torvalds committed Jun 28, 2016
2 parents 18751e2 + 3627612 commit 02184c6
Showing 2 changed files with 21 additions and 12 deletions.
27 changes: 16 additions & 11 deletions drivers/power/power_supply_core.c
Original file line number Diff line number Diff line change
@@ -565,11 +565,12 @@ static int power_supply_read_temp(struct thermal_zone_device *tzd,

WARN_ON(tzd == NULL);
psy = tzd->devdata;
ret = psy->desc->get_property(psy, POWER_SUPPLY_PROP_TEMP, &val);
ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_TEMP, &val);
if (ret)
return ret;

/* Convert tenths of degree Celsius to milli degree Celsius. */
if (!ret)
*temp = val.intval * 100;
*temp = val.intval * 100;

return ret;
}
@@ -612,10 +613,12 @@ static int ps_get_max_charge_cntl_limit(struct thermal_cooling_device *tcd,
int ret;

psy = tcd->devdata;
ret = psy->desc->get_property(psy,
POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX, &val);
if (!ret)
*state = val.intval;
ret = power_supply_get_property(psy,
POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX, &val);
if (ret)
return ret;

*state = val.intval;

return ret;
}
@@ -628,10 +631,12 @@ static int ps_get_cur_chrage_cntl_limit(struct thermal_cooling_device *tcd,
int ret;

psy = tcd->devdata;
ret = psy->desc->get_property(psy,
POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT, &val);
if (!ret)
*state = val.intval;
ret = power_supply_get_property(psy,
POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT, &val);
if (ret)
return ret;

*state = val.intval;

return ret;
}
6 changes: 5 additions & 1 deletion drivers/power/tps65217_charger.c
Original file line number Diff line number Diff line change
@@ -197,6 +197,7 @@ static int tps65217_charger_probe(struct platform_device *pdev)
{
struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent);
struct tps65217_charger *charger;
struct power_supply_config cfg = {};
int ret;

dev_dbg(&pdev->dev, "%s\n", __func__);
@@ -208,9 +209,12 @@ static int tps65217_charger_probe(struct platform_device *pdev)
charger->tps = tps;
charger->dev = &pdev->dev;

cfg.of_node = pdev->dev.of_node;
cfg.drv_data = charger;

charger->ac = devm_power_supply_register(&pdev->dev,
&tps65217_charger_desc,
NULL);
&cfg);
if (IS_ERR(charger->ac)) {
dev_err(&pdev->dev, "failed: power supply register\n");
return PTR_ERR(charger->ac);

0 comments on commit 02184c6

Please sign in to comment.