alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: oe-kbuild@lists.linux.dev, Kiseok Jo <kiseok.jo@irondevice.com>,
	Mark Brown <broonie@kernel.org>
Cc: Kiseok Jo <kiseok.jo@irondevice.com>,
	alsa-devel@alsa-project.org, lkp@intel.com,
	application@irondevice.com, oe-kbuild-all@lists.linux.dev
Subject: Re: [PATCH 3/3] ASOC: sma1303: change the overall contents
Date: Fri, 6 Jan 2023 10:51:30 +0300	[thread overview]
Message-ID: <202301060752.Z9ahR5KX-lkp@intel.com> (raw)
In-Reply-To: <20230104064342.2094-4-kiseok.jo@irondevice.com>

Hi Kiseok,

https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Kiseok-Jo/ASoC-sma1303-Add-driver-for-Iron-Device-SMA1303-Amp/20230104-150052
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
patch link:    https://lore.kernel.org/r/20230104064342.2094-4-kiseok.jo%40irondevice.com
patch subject: [PATCH 3/3] ASOC: sma1303: change the overall contents
config: ia64-randconfig-m041-20230101
compiler: ia64-linux-gcc (GCC) 12.1.0

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>

smatch warnings:
sound/soc/codecs/sma1303.c:257 sma1303_regmap_write() error: uninitialized symbol 'ret'.
sound/soc/codecs/sma1303.c:275 sma1303_regmap_update_bits() error: uninitialized symbol 'ret'.
sound/soc/codecs/sma1303.c:293 sma1303_regmap_read() error: uninitialized symbol 'ret'.
sound/soc/codecs/sma1303.c:684 sma1303_add_component_controls() error: not allocating enough for = 'name' 8 vs 3
	(This should allocate sizeof() not ARRAY_SIZE()).
sound/soc/codecs/sma1303.c:1539 sma1303_i2c_probe() warn: unsigned 'value' is never less than zero.

vim +/ret +257 sound/soc/codecs/sma1303.c

287cf116194f9c Kiseok Jo 2023-01-04  242  static int sma1303_regmap_write(struct sma1303_priv *sma1303,
0b15568ccfb962 Kiseok Jo 2023-01-04  243  				unsigned int reg, unsigned int val)
0b15568ccfb962 Kiseok Jo 2023-01-04  244  {
287cf116194f9c Kiseok Jo 2023-01-04  245  	int ret;
287cf116194f9c Kiseok Jo 2023-01-04  246  	int cnt = sma1303->retry_cnt;
0b15568ccfb962 Kiseok Jo 2023-01-04  247  
287cf116194f9c Kiseok Jo 2023-01-04  248  	while (cnt--) {

The way I look at it, you need three bugs for this to affect real life:

BUG 1: sma1303_regmap_write() is not written robustly (this warning).
BUG 2: sma1303_i2c_probe() allows sma1303->retry_cnt of zero (it does).
BUG 3: The i2c-retry_count is set to zero.  (Probably not but also not
       unimaginable).

So, yeah, let's fix BUG 2 because retry_cnt of zero is bogus.

                if (!of_property_read_u32(np, "i2c-retry_count", &value)) {
-                        if (value > 50 || value < 0) {
+                        if (value > 50 || value <= 0) {
                                sma1303->retry_cnt = SMA1303_I2C_RETRY_COUNT;

And BUG 1 to make the checker happy.

-  	int ret;
+  	int ret = -EINVAL;

287cf116194f9c Kiseok Jo 2023-01-04  249  		ret = regmap_write(sma1303->regmap, reg, val);
0b15568ccfb962 Kiseok Jo 2023-01-04  250  		if (ret < 0) {
287cf116194f9c Kiseok Jo 2023-01-04  251  			dev_err(sma1303->dev, "Failed to write [0x%02X]\n", reg);
287cf116194f9c Kiseok Jo 2023-01-04  252  			if (gCallback.set_i2c_err)
287cf116194f9c Kiseok Jo 2023-01-04  253  				gCallback.set_i2c_err(sma1303->dev, ret);
287cf116194f9c Kiseok Jo 2023-01-04  254  		} else
287cf116194f9c Kiseok Jo 2023-01-04  255  			break;
0b15568ccfb962 Kiseok Jo 2023-01-04  256  	}
0b15568ccfb962 Kiseok Jo 2023-01-04 @257  	return ret;
0b15568ccfb962 Kiseok Jo 2023-01-04  258  }
0b15568ccfb962 Kiseok Jo 2023-01-04  259  
287cf116194f9c Kiseok Jo 2023-01-04  260  static int sma1303_regmap_update_bits(struct sma1303_priv *sma1303,
0b15568ccfb962 Kiseok Jo 2023-01-04  261  		unsigned int reg, unsigned int mask, unsigned int val)
0b15568ccfb962 Kiseok Jo 2023-01-04  262  {
287cf116194f9c Kiseok Jo 2023-01-04  263  	int ret;
287cf116194f9c Kiseok Jo 2023-01-04  264  	int cnt = sma1303->retry_cnt;
0b15568ccfb962 Kiseok Jo 2023-01-04  265  
287cf116194f9c Kiseok Jo 2023-01-04  266  	while (cnt--) {
287cf116194f9c Kiseok Jo 2023-01-04  267  		ret = regmap_update_bits(sma1303->regmap, reg, mask, val);
0b15568ccfb962 Kiseok Jo 2023-01-04  268  		if (ret < 0) {
287cf116194f9c Kiseok Jo 2023-01-04  269  			dev_err(sma1303->dev, "Failed to update [0x%02X]\n", reg);
287cf116194f9c Kiseok Jo 2023-01-04  270  			if (gCallback.set_i2c_err)
287cf116194f9c Kiseok Jo 2023-01-04  271  				gCallback.set_i2c_err(sma1303->dev, ret);
287cf116194f9c Kiseok Jo 2023-01-04  272  		} else
287cf116194f9c Kiseok Jo 2023-01-04  273  			break;
0b15568ccfb962 Kiseok Jo 2023-01-04  274  	}
0b15568ccfb962 Kiseok Jo 2023-01-04 @275  	return ret;
0b15568ccfb962 Kiseok Jo 2023-01-04  276  }
0b15568ccfb962 Kiseok Jo 2023-01-04  277  
287cf116194f9c Kiseok Jo 2023-01-04  278  static int sma1303_regmap_read(struct sma1303_priv *sma1303,
287cf116194f9c Kiseok Jo 2023-01-04  279  		unsigned int reg, unsigned int *val)
0b15568ccfb962 Kiseok Jo 2023-01-04  280  {
287cf116194f9c Kiseok Jo 2023-01-04  281  	int ret;
287cf116194f9c Kiseok Jo 2023-01-04  282  	int cnt = sma1303->retry_cnt;
0b15568ccfb962 Kiseok Jo 2023-01-04  283  
287cf116194f9c Kiseok Jo 2023-01-04  284  	while (cnt--) {
287cf116194f9c Kiseok Jo 2023-01-04  285  		ret = regmap_read(sma1303->regmap, reg, val);
0b15568ccfb962 Kiseok Jo 2023-01-04  286  		if (ret < 0) {
287cf116194f9c Kiseok Jo 2023-01-04  287  			dev_err(sma1303->dev, "Failed to read [0x%02X]\n", reg);
287cf116194f9c Kiseok Jo 2023-01-04  288  			if (gCallback.set_i2c_err)
287cf116194f9c Kiseok Jo 2023-01-04  289  				gCallback.set_i2c_err(sma1303->dev, ret);
287cf116194f9c Kiseok Jo 2023-01-04  290  		} else
287cf116194f9c Kiseok Jo 2023-01-04  291  			break;
0b15568ccfb962 Kiseok Jo 2023-01-04  292  	}
287cf116194f9c Kiseok Jo 2023-01-04 @293  	return ret;
0b15568ccfb962 Kiseok Jo 2023-01-04  294  }

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests


      parent reply	other threads:[~2023-01-06  7:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-04  6:43 [PATCH 0/3] ASoC: Add a driver for the Iron Device SMA1303 Amp Kiseok Jo
2023-01-04  6:43 ` [PATCH 1/3] ASoC: sma1303: Add driver for " Kiseok Jo
2023-01-04 19:52   ` kernel test robot
2023-01-05 13:44   ` kernel test robot
2023-01-04  6:43 ` [PATCH 2/3] ASoC: dt-bindings: sma1303: " Kiseok Jo
2023-01-04  6:43 ` [PATCH 3/3] ASOC: sma1303: change the overall contents Kiseok Jo
2023-01-04 10:36   ` kernel test robot
2023-01-04 13:17   ` Mark Brown
2023-01-04 18:10   ` kernel test robot
2023-01-06  7:51   ` Dan Carpenter [this message]

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=202301060752.Z9ahR5KX-lkp@intel.com \
    --to=error27@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=application@irondevice.com \
    --cc=broonie@kernel.org \
    --cc=kiseok.jo@irondevice.com \
    --cc=lkp@intel.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=oe-kbuild@lists.linux.dev \
    /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;
as well as URLs for NNTP newsgroup(s).