| .. | .. |
|---|
| 328 | 328 | u8 i; |
|---|
| 329 | 329 | u16 d; |
|---|
| 330 | 330 | |
|---|
| 331 | + if (size < 2) |
|---|
| 332 | + return 0; |
|---|
| 333 | + |
|---|
| 331 | 334 | for (i = 0; i < size; i++) { |
|---|
| 332 | 335 | if (value < table[i]) |
|---|
| 333 | 336 | break; |
|---|
| .. | .. |
|---|
| 2965 | 2968 | FINISH_CHRG_CUR2 : FINISH_CHRG_CUR1; |
|---|
| 2966 | 2969 | finish_sec = base2sec(di->chrg_finish_base); |
|---|
| 2967 | 2970 | soc_sec = di->fcc * 3600 / 100 / DIV(finish_current); |
|---|
| 2971 | + if (soc_sec == 0) |
|---|
| 2972 | + soc_sec = 1; |
|---|
| 2968 | 2973 | plus_soc = finish_sec / DIV(soc_sec); |
|---|
| 2969 | 2974 | if (finish_sec > soc_sec) { |
|---|
| 2970 | 2975 | rest = finish_sec % soc_sec; |
|---|
| .. | .. |
|---|
| 4671 | 4676 | } |
|---|
| 4672 | 4677 | |
|---|
| 4673 | 4678 | pdata->ocv_size = length / sizeof(u32); |
|---|
| 4674 | | - if (pdata->ocv_size <= 0) { |
|---|
| 4679 | + if (pdata->ocv_size < 2) { |
|---|
| 4675 | 4680 | dev_err(dev, "invalid ocv table\n"); |
|---|
| 4676 | 4681 | return -EINVAL; |
|---|
| 4677 | 4682 | } |
|---|