lkml.org 
[lkml]   [2022]   [Jan]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subject[ammarfaizi2-block:broonie/sound/for-5.17 180/185] sound/soc/soc-ops.c:431 snd_soc_put_volsw_sx() warn: unsigned 'val' is never less than zero.
tree:   https://github.com/ammarfaizi2/linux-block broonie/sound/for-5.17
head: 8f2e5c65ec7534cce6d315fccf2c3aef023f68f0
commit: 4f1e50d6a9cf9c1b8c859d449b5031cacfa8404e [180/185] ASoC: ops: Reject out of bounds values in snd_soc_put_volsw_sx()
config: openrisc-randconfig-m031-20220124 (https://download.01.org/0day-ci/archive/20220127/202201270218.r8eL9ziw-lkp@intel.com/config)
compiler: or1k-linux-gcc (GCC) 11.2.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

New smatch warnings:
sound/soc/soc-ops.c:431 snd_soc_put_volsw_sx() warn: unsigned 'val' is never less than zero.

Old smatch warnings:
sound/soc/soc-ops.c:324 snd_soc_put_volsw() warn: unsigned 'val' is never less than zero.
sound/soc/soc-ops.c:337 snd_soc_put_volsw() warn: unsigned 'val2' is never less than zero.

vim +/val +431 sound/soc/soc-ops.c

399
400 /**
401 * snd_soc_put_volsw_sx - double mixer set callback
402 * @kcontrol: mixer control
403 * @ucontrol: control element information
404 *
405 * Callback to set the value of a double mixer control that spans 2 registers.
406 *
407 * Returns 0 for success.
408 */
409 int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
410 struct snd_ctl_elem_value *ucontrol)
411 {
412 struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
413 struct soc_mixer_control *mc =
414 (struct soc_mixer_control *)kcontrol->private_value;
415
416 unsigned int reg = mc->reg;
417 unsigned int reg2 = mc->rreg;
418 unsigned int shift = mc->shift;
419 unsigned int rshift = mc->rshift;
420 int max = mc->max;
421 int min = mc->min;
422 unsigned int mask = (1U << (fls(min + max) - 1)) - 1;
423 int err = 0;
424 unsigned int val, val_mask;
425
426 val = ucontrol->value.integer.value[0];
427 if (mc->platform_max && val > mc->platform_max)
428 return -EINVAL;
429 if (val > max - min)
430 return -EINVAL;
> 431 if (val < 0)
432 return -EINVAL;
433 val_mask = mask << shift;
434 val = (val + min) & mask;
435 val = val << shift;
436
437 err = snd_soc_component_update_bits(component, reg, val_mask, val);
438 if (err < 0)
439 return err;
440
441 if (snd_soc_volsw_is_stereo(mc)) {
442 unsigned int val2;
443
444 val_mask = mask << rshift;
445 val2 = (ucontrol->value.integer.value[1] + min) & mask;
446 val2 = val2 << rshift;
447
448 err = snd_soc_component_update_bits(component, reg2, val_mask,
449 val2);
450 }
451 return err;
452 }
453 EXPORT_SYMBOL_GPL(snd_soc_put_volsw_sx);
454

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

\
 
 \ /
  Last update: 2022-01-26 19:33    [W:0.044 / U:0.756 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site