File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -316,13 +316,27 @@ int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
316
316
if (sign_bit )
317
317
mask = BIT (sign_bit + 1 ) - 1 ;
318
318
319
- val = ((ucontrol -> value .integer .value [0 ] + min ) & mask );
319
+ val = ucontrol -> value .integer .value [0 ];
320
+ if (mc -> platform_max && val > mc -> platform_max )
321
+ return - EINVAL ;
322
+ if (val > max - min )
323
+ return - EINVAL ;
324
+ if (val < 0 )
325
+ return - EINVAL ;
326
+ val = (val + min ) & mask ;
320
327
if (invert )
321
328
val = max - val ;
322
329
val_mask = mask << shift ;
323
330
val = val << shift ;
324
331
if (snd_soc_volsw_is_stereo (mc )) {
325
- val2 = ((ucontrol -> value .integer .value [1 ] + min ) & mask );
332
+ val2 = ucontrol -> value .integer .value [1 ];
333
+ if (mc -> platform_max && val2 > mc -> platform_max )
334
+ return - EINVAL ;
335
+ if (val2 > max - min )
336
+ return - EINVAL ;
337
+ if (val2 < 0 )
338
+ return - EINVAL ;
339
+ val2 = (val2 + min ) & mask ;
326
340
if (invert )
327
341
val2 = max - val2 ;
328
342
if (reg == reg2 ) {
You can’t perform that action at this time.
0 commit comments