mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Mark Brown <broonie@kernel.org>
Cc: kbuild-all@lists.01.org, GNU/Weeb Mailing List <gwml@gnuweeb.org>,
	linux-kernel@vger.kernel.org
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.
Date: Thu, 27 Jan 2022 02:31:54 +0800	[thread overview]
Message-ID: <202201270218.r8eL9ziw-lkp@intel.com> (raw)

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

                 reply	other threads:[~2022-01-26 18:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202201270218.r8eL9ziw-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=broonie@kernel.org \
    --cc=gwml@gnuweeb.org \
    --cc=kbuild-all@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®