power: supply: cpcap-battery: Fix division by zero
Changes
1 files changed · +3 −0
| File | Status | Add | Del | Content |
|---|---|---|---|---|
| drivers/power/supply/cpcap-battery.c | modified | +3 | −0 | View file |
drivers/power/supply/cpcap-battery.c
View filediff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/cpcap-battery.c
index 08d5037..6887870 100644
--- a/drivers/power/supply/cpcap-battery.c
+++ b/drivers/power/supply/cpcap-battery.c
@@ -221,6 +221,9 @@ static int cpcap_battery_cc_raw_div(struct cpcap_battery_ddata *ddata,
int avg_current;
u32 cc_lsb;
+ if (!divider)
+ return 0;
+
sample &= 0xffffff; /* 24-bits, unsigned */
offset &= 0x7ff; /* 10-bits, signed */