Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8f0e2fb9 authored by Ashay Jaiswal's avatar Ashay Jaiswal Committed by Gerrit - the friendly Code Review server
Browse files

power: smb1390: fix NULL pointer de-reference in resume path



Add checks before accessing/de-referencing the pointers.
While at it, add a separate "is_writeable" callback for the slave
SMB1390.

Change-Id: I397f31b526e8d168a7c4bd2831c6dc5fe2fcc83e
Signed-off-by: default avatarAshay Jaiswal <ashayj@codeaurora.org>
parent d3d6e9be
Loading
Loading
Loading
Loading
+18 −3
Original line number Diff line number Diff line
@@ -1723,6 +1723,12 @@ static enum power_supply_property smb1390_cp_slave_props[] = {
	POWER_SUPPLY_PROP_CURRENT_CAPABILITY,
};

static int smb1390_slave_prop_is_writeable(struct power_supply *psy,
				enum power_supply_property prop)
{
	return 0;
}

static int smb1390_cp_slave_get_prop(struct power_supply *psy,
		enum power_supply_property psp,
		union power_supply_propval *val)
@@ -1781,7 +1787,7 @@ static const struct power_supply_desc cps_psy_desc = {
	.num_properties = ARRAY_SIZE(smb1390_cp_slave_props),
	.get_property = smb1390_cp_slave_get_prop,
	.set_property = smb1390_cp_slave_set_prop,
	.property_is_writeable	= smb1390_prop_is_writeable,
	.property_is_writeable = smb1390_slave_prop_is_writeable,
};

static int smb1390_init_cps_psy(struct smb1390 *chip)
@@ -1923,7 +1929,16 @@ static int smb1390_resume(struct device *dev)
	struct smb1390 *chip = dev_get_drvdata(dev);

	chip->suspended = false;

	/* ILIM rerun is applicable for both master and slave */
	if (!chip->ilim_votable)
		chip->ilim_votable = find_votable("CP_ILIM");

	if (chip->ilim_votable)
		rerun_election(chip->ilim_votable);

	/* Run disable votable for master only */
	if (chip->cp_role == CP_MASTER)
		rerun_election(chip->disable_votable);

	return 0;