Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933363AbcCGXtI (ORCPT ); Mon, 7 Mar 2016 18:49:08 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:44294 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933655AbcCGXqk (ORCPT ); Mon, 7 Mar 2016 18:46:40 -0500 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai Subject: [PATCH 3.14 21/36] ALSA: hdspm: Fix zero-division Date: Mon, 7 Mar 2016 15:46:04 -0800 Message-Id: <20160307234603.437507221@linuxfoundation.org> X-Mailer: git-send-email 2.7.2 In-Reply-To: <20160307234600.344036091@linuxfoundation.org> References: <20160307234600.344036091@linuxfoundation.org> User-Agent: quilt/0.64 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1445 Lines: 53 3.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Takashi Iwai commit c1099c3294c2344110085a38c50e478a5992b368 upstream. HDSPM driver contains a code issuing zero-division potentially in system sample rate ctl code. This patch fixes it by not processing a zero or invalid rate value as a divisor, as well as excluding the invalid value to be passed via the given ctl element. Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/pci/rme9652/hdspm.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c @@ -1602,6 +1602,9 @@ static void hdspm_set_dds_value(struct h { u64 n; + if (snd_BUG_ON(rate <= 0)) + return; + if (rate >= 112000) rate /= 4; else if (rate >= 56000) @@ -2224,6 +2227,8 @@ static int hdspm_get_system_sample_rate( } else { /* slave mode, return external sample rate */ rate = hdspm_external_sample_rate(hdspm); + if (!rate) + rate = hdspm->system_sample_rate; } } @@ -2269,7 +2274,10 @@ static int snd_hdspm_put_system_sample_r ucontrol) { struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); + int rate = ucontrol->value.integer.value[0]; + if (rate < 27000 || rate > 207000) + return -EINVAL; hdspm_set_dds_value(hdspm, ucontrol->value.integer.value[0]); return 0; }