From patchwork Mon Jan 1 04:40:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Banajit Goswami X-Patchwork-Id: 10138383 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2B01A60362 for ; Mon, 1 Jan 2018 04:46:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16AB32870C for ; Mon, 1 Jan 2018 04:46:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED95C2871A; Mon, 1 Jan 2018 04:46:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97CED2870C for ; Mon, 1 Jan 2018 04:46:21 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 09B4E266E07; Mon, 1 Jan 2018 05:46:20 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id C8C18266E67; Mon, 1 Jan 2018 05:46:16 +0100 (CET) Received: from smtp.codeaurora.org (smtp.codeaurora.org [198.145.29.96]) by alsa0.perex.cz (Postfix) with ESMTP id CE114266E02 for ; Mon, 1 Jan 2018 05:46:12 +0100 (CET) Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 4076C60B17; Mon, 1 Jan 2018 04:40:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1514781617; bh=hkZn4zKkQ22LfAqxAF74lm//+xI0iJbenPSKr5WjkUE=; h=From:To:Cc:Subject:Date:From; b=PmTsQstPPhB/WSF2DLcadrORC63rZTkBMbqFT+co6G/5SxFHvL2FtRwiwESKLzfjx sgb6vBRKRVYu6jw2UQflPBUcgihvhZzgxYcLD3ORhogEvr4V4daG8Ch1zpOg5Sa7Rn i5MTa7MV9MeT7CheyaaUEFSI80KVM2hh+xF1Xgmw= Received: from localhost (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: bgoswami@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id AA2A7602BD; Mon, 1 Jan 2018 04:40:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1514781616; bh=hkZn4zKkQ22LfAqxAF74lm//+xI0iJbenPSKr5WjkUE=; h=From:To:Cc:Subject:Date:From; b=b+73sa9M4W3e2Wo8cv9bBSAv9f0u16d/dPM83fsBPMZJufzsi29979DydohXfejBx GhPX0LTYkr9mM10/Mgu1fiRQ1xSnRZtSxjlBX+91rb0rcjGAgPA8E/aB7Y6fBSpMI1 AGYoxZrASg3ib5uKsBPJ0x2BAOfLuAifX1RHWRDU= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org AA2A7602BD Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=bgoswami@codeaurora.org From: bgoswami@codeaurora.org To: broonie@kernel.org Date: Sun, 31 Dec 2017 20:40:14 -0800 Message-Id: <1514781614-6039-1-git-send-email-bgoswami@codeaurora.org> X-Mailer: git-send-email 1.9.1 Cc: plai@qti.qualcomm.com, alsa-devel@alsa-project.org, Banajit Goswami Subject: [alsa-devel] [PATCH] ASoC: change mask in snd_soc_get/put_volsw_sx to unsigned int X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Banajit Goswami If the result of (min + max) is negative in functions snd_soc_get_volsw_sx() or snd_soc_put_volsw_sx(), there will be an overflow for the variable 'mask'. UBSAN: Undefined behaviour in sound/soc/soc-ops.c:382:6 signed integer overflow: -2147483648 - 1 cannot be represented in type 'int' Fix this by updating the variable type of 'mask' to unsigned int. Signed-off-by: Banajit Goswami --- sound/soc/soc-ops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c index 500f98c..7144a51 100644 --- a/sound/soc/soc-ops.c +++ b/sound/soc/soc-ops.c @@ -378,7 +378,7 @@ int snd_soc_get_volsw_sx(struct snd_kcontrol *kcontrol, unsigned int rshift = mc->rshift; int max = mc->max; int min = mc->min; - int mask = (1 << (fls(min + max) - 1)) - 1; + unsigned int mask = (1 << (fls(min + max) - 1)) - 1; unsigned int val; int ret; @@ -423,7 +423,7 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol, unsigned int rshift = mc->rshift; int max = mc->max; int min = mc->min; - int mask = (1 << (fls(min + max) - 1)) - 1; + unsigned int mask = (1 << (fls(min + max) - 1)) - 1; int err = 0; unsigned int val, val_mask, val2 = 0;