From patchwork Mon Feb 22 09:45:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clemens Ladisch X-Patchwork-Id: 2778 Return-path: Envelope-to: mchehab@infradead.org Delivery-date: Mon, 22 Feb 2010 09:45:51 +0000 Received: from bombadil.infradead.org [18.85.46.34] by pedra with IMAP (fetchmail-6.3.6) for (single-drop); Mon, 22 Feb 2010 07:51:08 -0300 (BRT) Received: from vger.kernel.org ([209.132.180.67]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NjUrP-0008HM-5b; Mon, 22 Feb 2010 09:45:51 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752489Ab0BVJpL (ORCPT + 1 other); Mon, 22 Feb 2010 04:45:11 -0500 Received: from out2.smtp.messagingengine.com ([66.111.4.26]:48324 "EHLO out2.smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751965Ab0BVJpK (ORCPT ); Mon, 22 Feb 2010 04:45:10 -0500 Received: from compute1.internal (compute1 [10.202.2.41]) by gateway1.messagingengine.com (Postfix) with ESMTP id 29EE9E251D; Mon, 22 Feb 2010 04:45:09 -0500 (EST) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute1.internal (MEProxy); Mon, 22 Feb 2010 04:45:09 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=messagingengine.com; h=message-id:date:from:mime-version:to:subject:content-type:content-transfer-encoding; s=smtpout; bh=eUOY7L958YxctupG2S35YkE/Oj4=; b=N74Yq1Ou9DSpJM4K2x3mDKmMTkL9hsXDK14RMx/5BiOfx1meje3T5+UmKomQeXUHFOBsSgkYz25QWw7evc6xndPJNPPNApxiGK/b6ZY1BLjNKmxOVfky88oCYIIxSn7X971EtPvg7MzwkQilsAk0v/ZN2Ezu1rDepi1XGU0B7wI= X-Sasl-enc: snH8vQErexCEG7kJgWB6be0RMajsVT5mVgYq3hBNvuSy 1266831908 Received: from [10.1.2.38] (srv004.schk01.int.dmc-one.com [85.232.8.141]) by mail.messagingengine.com (Postfix) with ESMTPSA id 6D29E4BB2E4; Mon, 22 Feb 2010 04:45:08 -0500 (EST) Message-ID: <4B825223.7030904@ladisch.de> Date: Mon, 22 Feb 2010 10:45:07 +0100 From: Clemens Ladisch User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] cx88-alsa: prevent out-of-range volume setting Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Ensure that volume values are always in the allowed range. Otherwise, it would be possible to set other bits in the AUD_VOL_CTL register or to get a wrong sign in the AUD_BAL_CTL register. Signed-off-by: Clemens Ladisch --- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- linux/drivers/media/video/cx88/cx88-alsa.c +++ linux/drivers/media/video/cx88/cx88-alsa.c @@ -583,16 +583,18 @@ static int snd_cx88_volume_put(struct sn { snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); struct cx88_core *core=chip->core; - int v, b; + int left, right, v, b; int changed = 0; u32 old; - b = value->value.integer.value[1] - value->value.integer.value[0]; + left = value->value.integer.value[0] & 0x3f; + right = value->value.integer.value[1] & 0x3f; + b = right - left; if (b < 0) { - v = 0x3f - value->value.integer.value[0]; + v = 0x3f - left; b = (-b) | 0x40; } else { - v = 0x3f - value->value.integer.value[1]; + v = 0x3f - right; } /* Do we really know this will always be called with IRQs on? */ spin_lock_irq(&chip->reg_lock);