Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp178226ybc; Mon, 18 Nov 2019 22:52:16 -0800 (PST) X-Google-Smtp-Source: APXvYqyyX1+P3zcD7CT7pptnxVnrHxV9qNhtSzJXv+qO7LYap3K07UomPl1gn37Kk575bnmOS6sF X-Received: by 2002:a17:907:40f2:: with SMTP id no2mr3036040ejb.250.1574146335975; Mon, 18 Nov 2019 22:52:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574146335; cv=none; d=google.com; s=arc-20160816; b=M5AR90cRio0w/041YoBw+rrfN0FXwJOQU4ZKHmQuhJnlZJ3By2I/TT5ehUyiByzN+v MNKIH75IEWysgo/HDrCT47ykA+47URjwa+JGiyQsDD+cf49TWWiXiJJ9lvr1+qhDvE6F jqHkKekYdA7aZm4nQSbi7B+uikTn6V8XQMUXlNuz89fj/CHj/tuwoyl0e/bvV1mR2jIE 3ZC92DEJRNE+peEY0J5mhuSGoq8oSheVdBHUzRuGu3myaDGSRi5TKHfCmTa5eoq+bKti D0tCV1KQ3rP8FwBzWUqiiu/YPBrI9p6LoswPH/e6ZZ2Q0Y8EFeZw2F9LcDhQpRRNg+mD wxZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XEl8K+eaqKtw6FMXq+I7ZOjyVGJDLiEJ8RApPE8SKno=; b=o5+GBZwRlSNC9hy4qK/a8BobV9I9QSDeKyhooNgfV3Xw0cawxP2L5+JO7dDZcp8JI9 BK1+ad4xbhOf1Zr0RATVRM8lIIIIyWYLxwGgOIIaXBAl0q19BjwYgEwIMwKircMnkIVg mzOzVP6IYv7sZmX5/MoQmKiN6Xhh/jHlqBC7z9qlWo3zYUiz+MAQpVc46SzePlvUPsiY XEHZ+SHK63tS8eRlYW6ePy+w0zhwpxdzwDUkWO6V2CiYkFZkz4oYNuXtkJU4TvbbIFev /DY7Qm6eUoQVrYx+dAnHnCgAjLZmyEffbbraX3ndDwTxEO1KwzyaZKiueLasKVTFahAN CTTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=V++aly+U; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b17si14854313edj.417.2019.11.18.22.51.50; Mon, 18 Nov 2019 22:52:15 -0800 (PST) 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=@kernel.org header.s=default header.b=V++aly+U; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728913AbfKSF2u (ORCPT + 99 others); Tue, 19 Nov 2019 00:28:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:47288 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728905AbfKSF2s (ORCPT ); Tue, 19 Nov 2019 00:28:48 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 502AC208C3; Tue, 19 Nov 2019 05:28:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574141327; bh=UNQs/91dK9j+/CpReb4++waTjXoKNuAIztVw5SJpU20=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V++aly+UEkxjPbkuVBz3AEBA61J91WfTSVSwwg95ayXMv+dm4qSZnrNYaOl/5U4LW 3mkII8/TD4EvSZuz4Zj8kc+AedwpALEI29F/+NIiIiv/0L1INBvdvwtZFageCdudxS 2THXXYq2FUS5lyiT3goqPEK60esH7J+9TBMIh2oc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Mark Brown , Sasha Levin Subject: [PATCH 4.19 123/422] ASoC: sgtl5000: avoid division by zero if lo_vag is zero Date: Tue, 19 Nov 2019 06:15:20 +0100 Message-Id: <20191119051406.971910930@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191119051400.261610025@linuxfoundation.org> References: <20191119051400.261610025@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King [ Upstream commit 9ab708aef61f5620113269a9d1bdb1543d1207d0 ] In the case where lo_vag <= SGTL5000_LINE_OUT_GND_BASE, lo_vag is set to zero and later vol_quot is computed by dividing by lo_vag causing a division by zero error. Fix this by avoiding a zero division and set vol_quot to zero in this specific case so that the lowest setting for i is correctly set. Signed-off-by: Colin Ian King Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/codecs/sgtl5000.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index 64a52d495b1f5..896412d11a31c 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c @@ -1387,7 +1387,7 @@ static int sgtl5000_set_power_regs(struct snd_soc_component *component) * Searching for a suitable index solving this formula: * idx = 40 * log10(vag_val / lo_cagcntrl) + 15 */ - vol_quot = (vag * 100) / lo_vag; + vol_quot = lo_vag ? (vag * 100) / lo_vag : 0; lo_vol = 0; for (i = 0; i < ARRAY_SIZE(vol_quot_table); i++) { if (vol_quot >= vol_quot_table[i]) -- 2.20.1