HID: input: Fix NULL pointer dereference when power_supply_register fails
Do not call power_supply_powers() if power_supply_register() failed earlier. This fixes possible NULL pointer dereference by power_supply_powers() in such case. Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Sebastian Reichel <sre@kernel.org>
This commit is contained in:
parent
8fb0885504
commit
fbea947c7d
@ -452,10 +452,10 @@ static bool hidinput_setup_battery(struct hid_device *dev, unsigned report_type,
|
||||
kfree(psy_desc->name);
|
||||
kfree(psy_desc);
|
||||
dev->battery = NULL;
|
||||
} else {
|
||||
power_supply_powers(dev->battery, &dev->dev);
|
||||
}
|
||||
|
||||
power_supply_powers(dev->battery, &dev->dev);
|
||||
|
||||
out:
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user