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-linus 179/181] sound/soc/soc-ops.c:324 snd_soc_put_volsw() warn: unsigned 'val' is never less than zero.
Date: Wed, 26 Jan 2022 21:57:06 +0800	[thread overview]
Message-ID: <202201262114.DuFfpPvs-lkp@intel.com> (raw)

tree:   https://github.com/ammarfaizi2/linux-block broonie/sound/for-linus
head:   4cf28e9ae6e2e11a044be1bcbcfa1b0d8675fe4d
commit: 817f7c9335ec01e0f5e8caffc4f1dcd5e458a4c0 [179/181] ASoC: ops: Reject out of bounds values in snd_soc_put_volsw()
config: openrisc-randconfig-m031-20220124 (https://download.01.org/0day-ci/archive/20220126/202201262114.DuFfpPvs-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>

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 +324 sound/soc/soc-ops.c

   285	
   286	/**
   287	 * snd_soc_put_volsw - single mixer put callback
   288	 * @kcontrol: mixer control
   289	 * @ucontrol: control element information
   290	 *
   291	 * Callback to set the value of a single mixer control, or a double mixer
   292	 * control that spans 2 registers.
   293	 *
   294	 * Returns 0 for success.
   295	 */
   296	int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
   297		struct snd_ctl_elem_value *ucontrol)
   298	{
   299		struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
   300		struct soc_mixer_control *mc =
   301			(struct soc_mixer_control *)kcontrol->private_value;
   302		unsigned int reg = mc->reg;
   303		unsigned int reg2 = mc->rreg;
   304		unsigned int shift = mc->shift;
   305		unsigned int rshift = mc->rshift;
   306		int max = mc->max;
   307		int min = mc->min;
   308		unsigned int sign_bit = mc->sign_bit;
   309		unsigned int mask = (1 << fls(max)) - 1;
   310		unsigned int invert = mc->invert;
   311		int err;
   312		bool type_2r = false;
   313		unsigned int val2 = 0;
   314		unsigned int val, val_mask;
   315	
   316		if (sign_bit)
   317			mask = BIT(sign_bit + 1) - 1;
   318	
   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;
   327		if (invert)
   328			val = max - val;
   329		val_mask = mask << shift;
   330		val = val << shift;
   331		if (snd_soc_volsw_is_stereo(mc)) {
   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;
   340			if (invert)
   341				val2 = max - val2;
   342			if (reg == reg2) {
   343				val_mask |= mask << rshift;
   344				val |= val2 << rshift;
   345			} else {
   346				val2 = val2 << shift;
   347				type_2r = true;
   348			}
   349		}
   350		err = snd_soc_component_update_bits(component, reg, val_mask, val);
   351		if (err < 0)
   352			return err;
   353	
   354		if (type_2r)
   355			err = snd_soc_component_update_bits(component, reg2, val_mask,
   356				val2);
   357	
   358		return err;
   359	}
   360	EXPORT_SYMBOL_GPL(snd_soc_put_volsw);
   361	

---
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 13:58 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=202201262114.DuFfpPvs-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

Powered by JetHome