mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: "Colin King" <colin.king@canonical.com>
Cc: <alsa-devel@alsa-project.org>,
	"Oleksandr Andrushchenko" <oleksandr_andrushchenko@epam.com>,
	<xen-devel@lists.xenproject.org>,
	"Jaroslav Kysela" <perex@perex.cz>,
	<kernel-janitors@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ALSA: xen-front: fix unintention integer overflow on left shifts
Date: Fri, 28 Jun 2019 10:46:59 +0200	[thread overview]
Message-ID: <s5hv9wq6qrg.wl-tiwai@suse.de> (raw)
In-Reply-To: <20190627165853.21864-1-colin.king@canonical.com>

On Thu, 27 Jun 2019 18:58:53 +0200,
Colin King wrote:
> 
> From: Colin Ian King <colin.king@canonical.com>
> 
> Shifting the integer value 1 is evaluated using 32-bit
> arithmetic and then used in an expression that expects a 64-bit
> value, so there is potentially an integer overflow. Fix this
> by using the BIT_ULL macro to perform the shift.
> 
> Addresses-Coverity: ("Unintentional integer overflow")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

The fix is correct, but luckily we didn't hit the integer overflow, as
all passed values are less than 32bit.

In anyway, applied now.  Thanks.


Takashi

> ---
>  sound/xen/xen_snd_front_alsa.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/xen/xen_snd_front_alsa.c b/sound/xen/xen_snd_front_alsa.c
> index b14ab512c2ce..e01631959ed8 100644
> --- a/sound/xen/xen_snd_front_alsa.c
> +++ b/sound/xen/xen_snd_front_alsa.c
> @@ -196,7 +196,7 @@ static u64 to_sndif_formats_mask(u64 alsa_formats)
>  	mask = 0;
>  	for (i = 0; i < ARRAY_SIZE(ALSA_SNDIF_FORMATS); i++)
>  		if (pcm_format_to_bits(ALSA_SNDIF_FORMATS[i].alsa) & alsa_formats)
> -			mask |= 1 << ALSA_SNDIF_FORMATS[i].sndif;
> +			mask |= BIT_ULL(ALSA_SNDIF_FORMATS[i].sndif);
>  
>  	return mask;
>  }
> @@ -208,7 +208,7 @@ static u64 to_alsa_formats_mask(u64 sndif_formats)
>  
>  	mask = 0;
>  	for (i = 0; i < ARRAY_SIZE(ALSA_SNDIF_FORMATS); i++)
> -		if (1 << ALSA_SNDIF_FORMATS[i].sndif & sndif_formats)
> +		if (BIT_ULL(ALSA_SNDIF_FORMATS[i].sndif) & sndif_formats)
>  			mask |= pcm_format_to_bits(ALSA_SNDIF_FORMATS[i].alsa);
>  
>  	return mask;
> -- 
> 2.20.1
> 
> 

  reply	other threads:[~2019-06-28  8:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-27 16:58 Colin King
2019-06-28  8:46 ` Takashi Iwai [this message]
2019-07-01  5:46   ` [Xen-devel] " Oleksandr Andrushchenko

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=s5hv9wq6qrg.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=colin.king@canonical.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleksandr_andrushchenko@epam.com \
    --cc=perex@perex.cz \
    --cc=xen-devel@lists.xenproject.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®