All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vinod Koul <vkoul@kernel.org>
To: Richard Fitzgerald <rf@opensource.cirrus.com>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	yung-chuan.liao@linux.intel.com, sanyog.r.kale@intel.com,
	alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	patches@opensource.cirrus.com
Subject: Re: [PATCH 1/2] soundwire: bus: Prevent infinite loop in sdw_ch_mask_to_ch()
Date: Wed, 15 Mar 2023 19:13:10 +0530	[thread overview]
Message-ID: <ZBHLbksMqwnewtMC@matsya> (raw)
In-Reply-To: <2d1f1bc1-afaa-b1f4-1a93-df1bfa00405b@opensource.cirrus.com>

On 03-02-23, 16:18, Richard Fitzgerald wrote:
> On 03/02/2023 14:35, Pierre-Louis Bossart wrote:
> > 
> > 
> > On 2/2/23 09:42, Richard Fitzgerald wrote:
> > > Define the ch_mask argument of sdw_ch_mask_to_ch() as an unsigned
> > > so that the shift right is guaranteed to eventually make the
> > > value of ch_mask==0.
> > > 
> > > Previously ch_mask was defined as a signed int, but a right
> > > shift of a signed value preserves the sign bit. So if the sign
> > > bit was 1, ch_mask would never become 0 and the for loop would
> > > be infinite.
> > > Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
> > > ---
> > >   drivers/soundwire/bus.h | 2 +-
> > >   1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/soundwire/bus.h b/drivers/soundwire/bus.h
> > > index 7631ef5e71fb..28bedc919b78 100644
> > > --- a/drivers/soundwire/bus.h
> > > +++ b/drivers/soundwire/bus.h
> > > @@ -160,7 +160,7 @@ int sdw_fill_msg(struct sdw_msg *msg, struct sdw_slave *slave,
> > >   		 u32 addr, size_t count, u16 dev_num, u8 flags, u8 *buf);
> > >   /* Retrieve and return channel count from channel mask */
> > > -static inline int sdw_ch_mask_to_ch(int ch_mask)
> > > +static inline int sdw_ch_mask_to_ch(unsigned int ch_mask)
> > >   {
> > >   	int c = 0;
> > 
> > This patch1 is fine, but you remove this function in patch2, so is this
> > patch needed at all?
> > 
> > -/* Retrieve and return channel count from channel mask */
> > -static inline int sdw_ch_mask_to_ch(unsigned int ch_mask)
> > -{
> > -	int c = 0;
> > -
> > -	for (c = 0; ch_mask; ch_mask >>= 1)
> > -		c += ch_mask & 1;
> > -
> > -	return c;
> > -}
> > -
> 
> I'm happy to squash them, I did it in two steps so it didn't get
> overlooked that there's a bugfix happening.

I think this case is fine to squash and send as a single patch while
documenting that we are fixing the bug in the log

Thanks
-- 
~Vinod

  reply	other threads:[~2023-03-15 13:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-02 15:42 [PATCH 0/2] soundwire: bus: Prevent infinite loop in sdw_ch_mask_to_ch() Richard Fitzgerald
2023-02-02 15:42 ` Richard Fitzgerald
2023-02-02 15:42 ` [PATCH 1/2] " Richard Fitzgerald
2023-02-02 15:42   ` Richard Fitzgerald
2023-02-03 14:35   ` Pierre-Louis Bossart
2023-02-03 14:35     ` Pierre-Louis Bossart
2023-02-03 16:18     ` Richard Fitzgerald
2023-02-03 16:18       ` Richard Fitzgerald
2023-03-15 13:43       ` Vinod Koul [this message]
2023-02-02 15:42 ` [PATCH 2/2] soundwire: bandwidth allocation: Use hweight32() to calculate set bits Richard Fitzgerald
2023-02-02 15:42   ` Richard Fitzgerald

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=ZBHLbksMqwnewtMC@matsya \
    --to=vkoul@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=rf@opensource.cirrus.com \
    --cc=sanyog.r.kale@intel.com \
    --cc=yung-chuan.liao@linux.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.