All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Ki-Seok Jo <kiseok.jo@irondevice.com>
Cc: "alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
	Mark Brown <broonie@kernel.org>,
	Application <application@irondevice.com>,
	kernel test robot <lkp@intel.com>
Subject: Re: [PATCH 14/14] Fixed the retry_cnt bug about being zero
Date: Fri, 6 Jan 2023 13:16:12 +0300	[thread overview]
Message-ID: <Y7f07Fa1LNpLP7ok@kadam> (raw)
In-Reply-To: <SLXP216MB0077B3BA3C18AD8F5A10F9708CFB9@SLXP216MB0077.KORP216.PROD.OUTLOOK.COM>

On Fri, Jan 06, 2023 at 09:55:43AM +0000, Ki-Seok Jo wrote:
> >> @@ -772,12 +772,13 @@ static int sma1303_add_component_controls(struct snd_soc_component *component)
> >>  	sma1303_controls = devm_kzalloc(sma1303->dev,
> >>  			sizeof(sma1303_snd_controls), GFP_KERNEL);
> >>  	name = devm_kzalloc(sma1303->dev,
> >> -			ARRAY_SIZE(sma1303_snd_controls), GFP_KERNEL);
> >> +			ARRAY_SIZE(sma1303_snd_controls)*sizeof(char *),
> >> +			GFP_KERNEL);
> 
> >I am surprised checkpatch doesn't complain that spaces are required around the * operator.  Please just use sizeof(sma1303_snd_controls).
> Otherwise you have to use devm_kcalloc() to avoid checkers warning about integer overflows.
> 
> I lost space between * operator. Thanks. (why didn't checkpatch check it? :(  )
> 
> But I don't understand why I use 'sizeof(sma1303_snd_controls)'.
> I only need to know the number of 'sma1303_snd_controls'.
> In 'sma1303_snd_controls', it has only 3.
> 
> So ARRAY_SIZE(sma1303_snd_controls) is 3, but sizeof(sma1303_snd_controls) has the value of 144.
> I think it's not necessary. What's the best?
> 

Ah.  Sorry, I didn't have enough context.  But could you instead use
sizeof(*name) instead of (char *) (it's the standard kernel style and
not just my opinion):

	name = devm_kcalloc(sma1303->dev, ARRAY_SIZE(sma1303_snd_controls),
			    sizeof(*name), GFP_KERNEL);

Also please declare name as char instead of unsigned char.
Also there needs to be some error checking for if the allocation fails.

This driver is going to need quite a bit of cleanup.  :/

regards,
dan carpenter


  reply	other threads:[~2023-01-06 10:17 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-06  9:15 [PATCH 00/14] ASoC: Add a driver the Iron Device SMA1303 AMP Kiseok Jo
2023-01-06  9:15 ` [PATCH 01/14] ASoC: sma1303: Add driver for Iron Device SMA1303 Amp Kiseok Jo
2023-01-06  9:15 ` [PATCH 02/14] ASoC: dt-bindings: sma1303: " Kiseok Jo
2023-01-06  9:15 ` [PATCH 03/14] Add the i2c-retry count and callback function in regmap function Kiseok Jo
2023-01-06  9:15 ` [PATCH 04/14] Removed the usage control and add the power switch on DAPM route Kiseok Jo
2023-01-06 13:59   ` Mark Brown
2023-01-09  9:33     ` Ki-Seok Jo
2023-01-06  9:15 ` [PATCH 05/14] Change the DAPM route and widgets Kiseok Jo
2023-01-06  9:15 ` [PATCH 06/14] Use the prefixs all definitions Kiseok Jo
2023-01-06  9:15 ` [PATCH 07/14] Remove the control of output format Kiseok Jo
2023-01-06  9:15 ` [PATCH 08/14] Remove the mute control Kiseok Jo
2023-01-06  9:15 ` [PATCH 09/14] Add the prefix for component controls Kiseok Jo
2023-01-06  9:15 ` [PATCH 10/14] Remove the shutdown and startup when set PLL Kiseok Jo
2023-01-06  9:15 ` [PATCH 11/14] Delete the header file of "linux/version.h" Kiseok Jo
2023-01-06  9:15 ` [PATCH 12/14] Add the postscaler's switch in DAPM manage Kiseok Jo
2023-01-06  9:15 ` [PATCH 13/14] Move the initial settings to i2c driver probe Kiseok Jo
2023-01-06  9:15 ` [PATCH 14/14] Fixed the retry_cnt bug about being zero Kiseok Jo
2023-01-06  9:27   ` Dan Carpenter
2023-01-06  9:30     ` Dan Carpenter
2023-01-06  9:59       ` Ki-Seok Jo
2023-01-06  9:55     ` Ki-Seok Jo
2023-01-06 10:16       ` Dan Carpenter [this message]
2023-01-07 12:37       ` Dan Carpenter
2023-01-09  7:33         ` Ki-Seok Jo
2023-01-09  8:17           ` Dan Carpenter
2023-01-09  8:35             ` Ki-Seok Jo

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=Y7f07Fa1LNpLP7ok@kadam \
    --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 \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.