if (controlNum == state->Init_Ctrl[i].Ctrl_Num) {
- highLimit = 1 << state->Init_Ctrl[i].size;
+ u16 size = min_t(u16, state->Init_Ctrl[i].size,
+ ARRAY_SIZE(state->Init_Ctrl[i].val));
+ highLimit = 1 << size;
if (value < highLimit) {
- for (j = 0; j < state->Init_Ctrl[i].size; j++) {
+ for (j = 0; j < size; j++) {
state->Init_Ctrl[i].val[j] = (u8)((value >> j) & 0x01);
MXL_RegWriteBit(fe, (u8)(state->Init_Ctrl[i].addr[j]),
(u8)(state->Init_Ctrl[i].bit[j]),
if (controlNum == state->CH_Ctrl[i].Ctrl_Num) {
- highLimit = 1 << state->CH_Ctrl[i].size;
+ u16 size = min_t(u16, state->CH_Ctrl[i].size,
+ ARRAY_SIZE(state->CH_Ctrl[i].val));
+ highLimit = 1 << size;
if (value < highLimit) {
- for (j = 0; j < state->CH_Ctrl[i].size; j++) {
+ for (j = 0; j < size; j++) {
state->CH_Ctrl[i].val[j] = (u8)((value >> j) & 0x01);
MXL_RegWriteBit(fe, (u8)(state->CH_Ctrl[i].addr[j]),
(u8)(state->CH_Ctrl[i].bit[j]),