Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4952998imm; Tue, 9 Oct 2018 07:37:07 -0700 (PDT) X-Google-Smtp-Source: ACcGV63t4nVftmiuL2jhyLhybodPbgvKzVO5WEjMesn1SdXJJgMU//tAdg4c/K+aKGaDP4jovtAM X-Received: by 2002:a65:4783:: with SMTP id e3-v6mr9251130pgs.12.1539095827452; Tue, 09 Oct 2018 07:37:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539095827; cv=none; d=google.com; s=arc-20160816; b=o3s0CILP88kD5igyNLqQjJk8FBKHfd0MbTMon4pKxCyQK8ndgax19VVwwF+54gC0eA m5O/Je2eBDyN2ZQbbmBMN+iS31r4RRtfGuc2farli4SJqOB9W54f7C/2bYxRyPoMfsAA j0HJzK4Hffd07rdx17/Aop3PNRmDR08efmk6nqCuCUfq2Diqey5Ur6c9tt3gYrtq0Pp7 /hwDUfwouwaw8aHshJ3C/mSfGjg1FjhlY/cMVGxbtQC/p/ppJiDyrhesh+OrhnT9AHLu TzZdtmh4h8Be2sFseXV9PSJqfPGJU4oNnumQOqAfVutUYCtMe9NAJNe6K9RoRAlqX98p /xFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=TmvjctwlEH2k+mWL682SP3FFbm0u41+Ro94eJ+jcraw=; b=pfHJFCW2Oy+34y1qo4biqGgo5VFqVRNRw3GKuU5WH/uuvO0ffwHyJTPHn18cpmbsM6 pbEqsD2YxY4StYymPZcC0RBG2uyRhzmTek6D7M+XIPsuqydjarKt9EkhKn/CYyYgHAl6 tt1mKkYsIUm76pKsTiLNyxXQLHkb5LFe7kd0ecR+WtjwbZRLe9udPucN+BDOttF9xqpp +6BrU33bNW/LHjNpvdRKvmqOsnN+p3TKBYD7e/hDTxW7nffqIYS7U7+HTMlQ2gAwyEbH fB15/0YDOPVcvUK6X3YsmiLLQ7nlRaLwbkw+pDnpEp4I4KbRlT/VNQAm7LFDkr9iJMKt nL8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@umn.edu header.s=google header.b=LMG35cAI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=umn.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b13-v6si20989314pgg.89.2018.10.09.07.36.52; Tue, 09 Oct 2018 07:37:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@umn.edu header.s=google header.b=LMG35cAI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=umn.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726563AbeJIVxV (ORCPT + 99 others); Tue, 9 Oct 2018 17:53:21 -0400 Received: from mta-p6.oit.umn.edu ([134.84.196.206]:39094 "EHLO mta-p6.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726418AbeJIVxV (ORCPT ); Tue, 9 Oct 2018 17:53:21 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-p6.oit.umn.edu (Postfix) with ESMTP id 93A7BEEA for ; Tue, 9 Oct 2018 14:36:06 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p6.oit.umn.edu ([127.0.0.1]) by localhost (mta-p6.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gyJXj9VU3O-B for ; Tue, 9 Oct 2018 09:36:06 -0500 (CDT) Received: from mail-io1-f71.google.com (mail-io1-f71.google.com [209.85.166.71]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p6.oit.umn.edu (Postfix) with ESMTPS id 60480DB8 for ; Tue, 9 Oct 2018 09:36:06 -0500 (CDT) Received: by mail-io1-f71.google.com with SMTP id p22-v6so1500949ioh.7 for ; Tue, 09 Oct 2018 07:36:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umn.edu; s=google; h=from:to:cc:subject:date:message-id; bh=TmvjctwlEH2k+mWL682SP3FFbm0u41+Ro94eJ+jcraw=; b=LMG35cAImYQRNJLRtvwvx+yIRhj25VcDBtHUeUwGYJ6p1fWI/NnQ+lKEPQ4NVEF9nn yhLhOYhq0zRraBBpxbNhfHWMCAUSTh3KCkR2aP5TJAWd85TxiKuhXn8AKJI7MTDJvhO1 7NU7JaL9a3kJ3oXbKd8WUvDU4RoUb76SE3Qa6H5lrsZZ7Z2vDg2nKNIRYARmHCUmYoaC uOnhzrYdKiORsd3H99SUSekTKPzNQvT7PCVp8NYfu19w4pZpT9Ht1vhJbUT4Y873p8ZI QSkb7xW9RyjQ5ub0u8I5dMZC7O631IvJ4/rtvLpZqZ2N0wh9rpsyd5S+7uxBt/eg0VvN FFAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=TmvjctwlEH2k+mWL682SP3FFbm0u41+Ro94eJ+jcraw=; b=QmmRc5Lz4T5VgjKbEmgBzxV0PdOopDqL4PiJAn74kTcPJt5Gf5TTtBudei7oRRIEro sRCcsksT6xXZFxui8n8A5sXo30LLXI4wTWwBvnYdE5wKu+Sb9RUMs6TeGkieRQ0KhOJN 7VhUsHU2QV+lbhnlR47gtmU/oXyMfFAQMRYz6e9wouRJJmZtoqAPsHMpQ3dil2Q5XcCi 6uUFzwqFtR3IOwZDGuJ26aTyXe010knkB7Ep5E+a7fGKaA4luSVXVssvjOryt2IwM/Vz 7kHe8LVEalX8AIADRnu3gB9FlU7YJKf0q71g+sOlws60+ijpuI+zaT1ltU5oKs1OSZam OhHg== X-Gm-Message-State: ABuFfoiXTXASgNfsVYhRGCnVISvNI+NC7gTpLdRfMUsFVNveI/0hWQq/ HOwoXnSAKhliCvTi39Eo9Gb43sgqrS8bOl21dWd4ZCQW2U3ukQSdhblhZlur+UaYsiu9L0UvIeH SMW4GFsZt9RrWe44NX6Uz3ioDIH89 X-Received: by 2002:a24:f58a:: with SMTP id k132-v6mr2102799ith.68.1539095765892; Tue, 09 Oct 2018 07:36:05 -0700 (PDT) X-Received: by 2002:a24:f58a:: with SMTP id k132-v6mr2102783ith.68.1539095765644; Tue, 09 Oct 2018 07:36:05 -0700 (PDT) Received: from cs-u-cslp16.cs.umn.edu (cs-u-cslp16.cs.umn.edu. [134.84.121.95]) by smtp.gmail.com with ESMTPSA id j75-v6sm6300825itj.33.2018.10.09.07.36.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Oct 2018 07:36:04 -0700 (PDT) From: Wenwen Wang To: Wenwen Wang Cc: Kangjie Lu , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org (moderated list:SOUND), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] ALSA: intel8x0: fix a redundant check bug Date: Tue, 9 Oct 2018 09:35:52 -0500 Message-Id: <1539095754-5609-1-git-send-email-wang6495@umn.edu> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In snd_intel8x0_codec_semaphore(), the parameter 'codec' is firstly checked to see whether it is greater than 2. If yes, an error code EIO is returned. Otherwise, 'chip->in_sdin_init' is further checked. If 'chip->in_sdin_init' is not zero, 'codec' is updated immediately with 'chip->codec_isr_bits'. That means, the parameter 'codec' is not used in this branch. Actually, it is only used in the else branch when 'chip->in_sdin_init' is zero. Thus, the check on the parameter 'codec' is redundant if 'chip->in_sdin_init' is not zero. This can cause potential incorrect execution in this function. Suppose the parameter 'codec' is 3, which is greater than 2, and 'chip->in_sdin_init' is not zero. The current version of this function will return EIO after the first check because 'codec' is greater than 2. However, since 'codec' will be updated in the following execution when 'chip->in_sdin_init' is not zero, this check will be meaningless and the execution should continue, instead of returning the error code EIO. This patch avoids the above issue by moving the check on the parameter 'codec' to the else branch of the if statement that checks 'chip->in_sdin_init'. Signed-off-by: Wenwen Wang --- sound/pci/intel8x0.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index 5ee468d..f619e58 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -515,13 +515,13 @@ static int snd_intel8x0_codec_semaphore(struct intel8x0 *chip, unsigned int code { int time; - if (codec > 2) - return -EIO; if (chip->in_sdin_init) { /* we don't know the ready bit assignment at the moment */ /* so we check any */ codec = chip->codec_isr_bits; } else { + if (codec > 2) + return -EIO; codec = chip->codec_bit[chip->ac97_sdin[codec]]; } -- 2.7.4