Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp524137pxf; Thu, 18 Mar 2021 06:24:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw22/15khnUh0a808fEe6prtYK3G7SdWRzKaHusTs8TsKw7Ezzfe1K/O08SyQpbQqo2i3R6 X-Received: by 2002:a17:906:ca02:: with SMTP id jt2mr41089654ejb.312.1616073870648; Thu, 18 Mar 2021 06:24:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616073870; cv=none; d=google.com; s=arc-20160816; b=WaxDieXtnr1BNK6qpVTK4YxsTjEktWwS00W6z6tc8fFuJkV6QxVlNYuNwh2sRTs19V jtSOcCDkAf82dbtVNavdWWMCS3Sr3AyPNNh4Nd0F6RjgfOteXTgq1hhJUg4UPB4NhIG2 j15/jwslz3PNPT8Qjs9ngkzsQn8B9XrcjEWzNfnvy22JxD0DRRchnYVnBCciEEPrM/i5 2cduZUl1xCCvB/mn+PA8ONgYCsS8PvS7QbkKIw8++k08BfZbv+/DD4km1R+61RUbEtTe joNMgaRlr0yk79uzceaZcbzaW/cXMKBh2pYb2RupNs4pt4d0EihGo433zVP9ruxeDxaY rbJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=qQGPukgaXOeqxg2iNsz3n9tPMJni8mgD+iNcu8tZfRQ=; b=npOsXRnvIrzt4SLCVsT2IJbGv4RHc6T/ljF18TVPP1oVymk2O6N0ytwvt64CJyfO1T Yde7kzSWxFycIK6bVekdpL5O7AQbEa0AHMvf/tJJLK627vkO4I6r7ekXrZVBXIvEZyMq rK7atpBAj9ipnzHKCmC1/9c038Bjz0Zl9vGGk+DnCj9bdB5EE3G4GUwvi5GbEs8AqPxh OYK4cuY1Kib5xhWfhkpyE/QDsAVYnA4N8ggxVaTlXQoPouseJ4oWsekPmEeKey8/DsRv JjYzEB/+ho6Ef6ZBx0m7U7GcgSb56BiT3JZ+w317EBFl+FVse5sJplA4WcZa4o0hmGbx k9Cg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y16si1606069edd.467.2021.03.18.06.24.07; Thu, 18 Mar 2021 06:24:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231414AbhCRNUp (ORCPT + 99 others); Thu, 18 Mar 2021 09:20:45 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:37952 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231256AbhCRNUP (ORCPT ); Thu, 18 Mar 2021 09:20:15 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lMsZN-0001kM-0q; Thu, 18 Mar 2021 13:20:09 +0000 From: Colin King To: Olivia Mackintosh , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ALSA: usb-audio: Fix unintentional sign extension issue Date: Thu, 18 Mar 2021 13:20:08 +0000 Message-Id: <20210318132008.15266-1-colin.king@canonical.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King The shifting of the u8 integer device by 24 bits to the left will be promoted to a 32 bit signed int and then sign-extended to a 64 bit unsigned long. In the event that the top bit of device is set then all then all the upper 32 bits of the unsigned long will end up as also being set because of the sign-extension. Fix this by casting device to an unsigned long before the shift. Addresses-Coverity: ("Unintended sign extension") Fixes: a07df82c7990 ("ALSA: usb-audio: Add DJM750 to Pioneer mixer quirk") Signed-off-by: Colin Ian King --- sound/usb/mixer_quirks.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c index 5b77e8140ba6..f13cdfd8bd20 100644 --- a/sound/usb/mixer_quirks.c +++ b/sound/usb/mixer_quirks.c @@ -2926,7 +2926,7 @@ static int snd_djm_controls_put(struct snd_kcontrol *kctl, struct snd_ctl_elem_v u8 group = (private_value & SND_DJM_GROUP_MASK) >> SND_DJM_GROUP_SHIFT; u16 value = elem->value.enumerated.item[0]; - kctl->private_value = ((device << SND_DJM_DEVICE_SHIFT) | + kctl->private_value = (((unsigned long)device << SND_DJM_DEVICE_SHIFT) | (group << SND_DJM_GROUP_SHIFT) | value); @@ -2964,7 +2964,7 @@ static int snd_djm_controls_create(struct usb_mixer_interface *mixer, value = device->controls[i].default_value; knew.name = device->controls[i].name; knew.private_value = ( - (device_idx << SND_DJM_DEVICE_SHIFT) | + ((unsigned long)device_idx << SND_DJM_DEVICE_SHIFT) | (i << SND_DJM_GROUP_SHIFT) | value); err = snd_djm_controls_update(mixer, device_idx, i, value); -- 2.30.2