From patchwork Sun Apr 8 09:02:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 10328245 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 8AA3660365 for ; Sun, 8 Apr 2018 09:02:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BADD28AED for ; Sun, 8 Apr 2018 09:02:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7000928CD9; Sun, 8 Apr 2018 09:02:47 +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=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham 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 4E82028AED for ; Sun, 8 Apr 2018 09:02:45 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id BDA34266D69; Sun, 8 Apr 2018 11:02:43 +0200 (CEST) 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 754B5266D8C; Sun, 8 Apr 2018 11:02:41 +0200 (CEST) Received: from michel.telenet-ops.be (michel.telenet-ops.be [195.130.137.88]) by alsa0.perex.cz (Postfix) with ESMTP id 52F9A266D47 for ; Sun, 8 Apr 2018 11:02:36 +0200 (CEST) Received: from ayla.of.borg ([84.194.111.163]) by michel.telenet-ops.be with bizsmtp id Xl2b1x01M3XaVaC06l2bWt; Sun, 08 Apr 2018 11:02:36 +0200 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.86_2) (envelope-from ) id 1f56Db-00053a-Kc; Sun, 08 Apr 2018 11:02:35 +0200 Received: from geert by ramsan with local (Exim 4.86_2) (envelope-from ) id 1f56Db-0000OG-Gb; Sun, 08 Apr 2018 11:02:35 +0200 From: Geert Uytterhoeven To: Srinivas Kandagatla , Greg Kroah-Hartman Date: Sun, 8 Apr 2018 11:02:34 +0200 Message-Id: <1523178154-1130-1-git-send-email-geert@linux-m68k.org> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, Mark Brown , Geert Uytterhoeven , linux-kernel@vger.kernel.org, Arnd Bergmann Subject: [alsa-devel] [PATCH] slimbus: Fix out-of-bounds access in slim_slicesize() 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP With gcc-4.1.2: slimbus/messaging.c: In function ‘slim_slicesize’: slimbus/messaging.c:186: warning: statement with no effect Indeed, clamp() is a macro not operating in-place, but returning the clamped value. Hence the value is not clamped at all, which may lead to an out-of-bounds access. Fix this by assigning the clamped value. Fixes: afbdcc7c384b0d44 ("slimbus: Add messaging APIs to slimbus framework") Signed-off-by: Geert Uytterhoeven --- drivers/slimbus/messaging.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/slimbus/messaging.c b/drivers/slimbus/messaging.c index 884419c37e8419c8..457ea1f8db309cb9 100644 --- a/drivers/slimbus/messaging.c +++ b/drivers/slimbus/messaging.c @@ -183,7 +183,7 @@ static u16 slim_slicesize(int code) 0, 1, 2, 3, 3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7 }; - clamp(code, 1, (int)ARRAY_SIZE(sizetocode)); + code = clamp(code, 1, (int)ARRAY_SIZE(sizetocode)); return sizetocode[code - 1]; }