From patchwork Sun May 27 21:32:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin King X-Patchwork-Id: 10429563 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 DD08060249 for ; Sun, 27 May 2018 21:32:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1C9728922 for ; Sun, 27 May 2018 21:32:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0E41289D7; Sun, 27 May 2018 21:32:33 +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 EB76828922 for ; Sun, 27 May 2018 21:32:32 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 478372673F0; Sun, 27 May 2018 23:32:31 +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 9CC802673F2; Sun, 27 May 2018 23:32:28 +0200 (CEST) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by alsa0.perex.cz (Postfix) with ESMTP id 00241267255 for ; Sun, 27 May 2018 23:32:26 +0200 (CEST) Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1fN3H1-0003NB-PC; Sun, 27 May 2018 21:32:19 +0000 From: Colin King To: Oleksandr Andrushchenko , Jaroslav Kysela , Takashi Iwai , xen-devel@lists.xenproject.org, alsa-devel@alsa-project.org Date: Sun, 27 May 2018 22:32:19 +0100 Message-Id: <20180527213219.24182-1-colin.king@canonical.com> X-Mailer: git-send-email 2.17.0 MIME-Version: 1.0 Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [alsa-devel] [PATCH][next] ALSA: xen-front: fix unsigned error check on return from to_sndif_format 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 From: Colin Ian King The negative error return from the call to to_sndif_format is being assigned to an unsigned 8 bit integer and hence the check for a negative value is always going to be false. Fix this by using ret as the error return and hence the negative error can be detected and assign the u8 sndif_format to ret if there is no error. Detected by CoverityScan, CID#1469385 ("Unsigned compared against 0") Signed-off-by: Colin Ian King Reviewed-by: Takashi Sakamoto --- sound/xen/xen_snd_front_alsa.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sound/xen/xen_snd_front_alsa.c b/sound/xen/xen_snd_front_alsa.c index 5041f83e98d2..5a2bd70a2fa1 100644 --- a/sound/xen/xen_snd_front_alsa.c +++ b/sound/xen/xen_snd_front_alsa.c @@ -466,13 +466,14 @@ static int alsa_prepare(struct snd_pcm_substream *substream) u8 sndif_format; int ret; - sndif_format = to_sndif_format(runtime->format); - if (sndif_format < 0) { + ret = to_sndif_format(runtime->format); + if (ret < 0) { dev_err(&stream->front_info->xb_dev->dev, "Unsupported sample format: %d\n", runtime->format); - return sndif_format; + return ret; } + sndif_format = ret; ret = xen_snd_front_stream_prepare(&stream->evt_pair->req, &stream->sh_buf,