From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AF74C43603 for ; Fri, 20 Dec 2019 09:33:02 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C779E2146E for ; Fri, 20 Dec 2019 09:33:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="tgVwbfH2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C779E2146E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id EFE4D84D; Fri, 20 Dec 2019 10:32:09 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz EFE4D84D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1576834380; bh=BGEqx+VE+f9Q+9vj8kfZlzNdHt4QpncOMJ3Afj31GHs=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=tgVwbfH2G0hpxG/7fhpPTm4q/GFc3X8ctwG0NGkG4uVQuLtKof7BVPzQ0i3UgJIXw py4ZeN1I8v2RTkP4pVJZmeqnuUOZqz9/qO3lIOp4tkhjivqoVQ4zFiS08UE7mC6Ubd J+YAIScmKuKXI+H19trPoCKMIzmvpjyRTXFD+ooA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 95926F8014F; Fri, 20 Dec 2019 10:32:09 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8172CF8015A; Fri, 20 Dec 2019 10:32:07 +0100 (CET) Received: from mail-lj1-f196.google.com (mail-lj1-f196.google.com [209.85.208.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 053F6F800B5 for ; Fri, 20 Dec 2019 10:32:04 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 053F6F800B5 Received: by mail-lj1-f196.google.com with SMTP id u71so9293182lje.11 for ; Fri, 20 Dec 2019 01:32:04 -0800 (PST) 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:mime-version :content-transfer-encoding; bh=vACzD6DaxQvgtCMU0tnPw1WJ51oVtIqk0pKAR9FuZpU=; b=r0IdfkfcouXY8AwHIUt0hOiPzVcxPzkuHnlkpxzrfMMHpjgU8Kx3XljwG3enn9hsNV t5Ry+IUaFYd2JPwxzOb4YYjwuubzUwFoX3rSiGI1RupwRk1symgo93DNQFpouOSOEbDk YB/pksCeqk94Dx4lhn/fts7VsTFoaWgkCrUReeHMp4/bESfyV4MXiycoKUk9OAZwaP3X HiThq2/lkibsSGVvuO6cFsRz78OMIRIros+sYiTIYIveVgWlQKQhrnAvq2Z6w2HXXAaD lpe4TTy0KyoqWs0qXaUgimphMXCxb+IXkLLnnsV3EWhbBavVZtYeRwU2ZNzvX56FQeRb Q2Hg== X-Gm-Message-State: APjAAAU64CMJwWkri52xYVrYB+t6/LyPbpjER6DRMwMabsOcGCHoeMa0 uEfGeWOZ6wtxecgt9Nh9Qo8= X-Google-Smtp-Source: APXvYqx7d4xmf7k72/iB+L72Tyd+ARo47ZmuVxirOZXppNqFPl+yhzLOboPX4ybagaHMNyeKmQuMow== X-Received: by 2002:a2e:910b:: with SMTP id m11mr9162003ljg.213.1576834323858; Fri, 20 Dec 2019 01:32:03 -0800 (PST) Received: from xi.terra (c-14b8e655.07-184-6d6c6d4.bbcust.telenor.se. [85.230.184.20]) by smtp.gmail.com with ESMTPSA id z7sm4437120lfa.81.2019.12.20.01.32.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2019 01:32:03 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.92.3) (envelope-from ) id 1iiEde-0000L0-4r; Fri, 20 Dec 2019 10:32:02 +0100 From: Johan Hovold To: Takashi Iwai Date: Fri, 20 Dec 2019 10:31:34 +0100 Message-Id: <20191220093134.1248-1-johan@kernel.org> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, Johan Hovold , linux-kernel@vger.kernel.org, stable Subject: [alsa-devel] [PATCH] ALSA: usb-audio: fix set_format altsetting sanity check X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Make sure to check the return value of usb_altnum_to_altsetting() to avoid dereferencing a NULL pointer when the requested alternate settings is missing. The format altsetting number may come from a quirk table and there does not seem to be any other validation of it (the corresponding index is checked however). Fixes: b099b9693d23 ("ALSA: usb-audio: Avoid superfluous usb_set_interface() calls") Cc: stable # 4.18 Signed-off-by: Johan Hovold --- sound/usb/pcm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 9c8930bb00c8..73dd9d21bb42 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -506,9 +506,9 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt) if (WARN_ON(!iface)) return -EINVAL; alts = usb_altnum_to_altsetting(iface, fmt->altsetting); - altsd = get_iface_desc(alts); - if (WARN_ON(altsd->bAlternateSetting != fmt->altsetting)) + if (WARN_ON(!alts)) return -EINVAL; + altsd = get_iface_desc(alts); if (fmt == subs->cur_audiofmt) return 0; -- 2.24.1 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org https://mailman.alsa-project.org/mailman/listinfo/alsa-devel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47E2FC3F68F for ; Fri, 20 Dec 2019 09:32:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 149072146E for ; Fri, 20 Dec 2019 09:32:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576834327; bh=2IWG2XB69BqHzXFt9VBjFmiioNKdGWnBh2Lll6Jmb6M=; h=From:To:Cc:Subject:Date:List-ID:From; b=kwdi4oBMEAGB2bVe6VwUOv3wSARpFNXer5jQgTc4M2sCSI5/zWmKBmj7YB9a55kvu fgn6ZyjrmTzUGXq63TqITZq4UgW+K4KXkdwM36zZB5kFcP7V3DZWgufPGDp38jhoGF twVjZIIUyBlBg1GKRwc84mA6kndfLLgrml6+igCc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727382AbfLTJcG (ORCPT ); Fri, 20 Dec 2019 04:32:06 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:35564 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727202AbfLTJcG (ORCPT ); Fri, 20 Dec 2019 04:32:06 -0500 Received: by mail-lj1-f195.google.com with SMTP id j1so1943879lja.2; Fri, 20 Dec 2019 01:32:04 -0800 (PST) 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:mime-version :content-transfer-encoding; bh=vACzD6DaxQvgtCMU0tnPw1WJ51oVtIqk0pKAR9FuZpU=; b=FySB0IZnaU+ESH8XGKR4HwoXuak1WTgE8SPhZAkiDiUF7QIqJIRz4MVTSMJUE1u42T Z/hJR0SKqpWsujre0cXxBwwLxYtI99RqvYRBDS0HJYdf26BC3GDs3TmrwWq2LZFzGI7n wHmnXiN1F0zqVB6Vf5ONeRtsup9ijMbT9FNllAvJ2ftNkOusvc1cH6HO2acP4WmQeDOG pW9r0gUausnDAAS2DrpmGRrO8Wa0nzDVR936dEWlp9dSWoLTC+fy/nkLEBxvg2wLclDP OWiDsZDqrnawS/D+/TZPfVBQJqfqEtjSlRYljp+fMk1BLlkKS2BQ+wcYpddBP7EMv3X4 AeJA== X-Gm-Message-State: APjAAAW7bodVb8QNmL5QIrHYRGpdsc/jaOpROe8GYwCpxw/uyEC/XbCw bdtSnthJen6P6iR05lI+0jI= X-Google-Smtp-Source: APXvYqx7d4xmf7k72/iB+L72Tyd+ARo47ZmuVxirOZXppNqFPl+yhzLOboPX4ybagaHMNyeKmQuMow== X-Received: by 2002:a2e:910b:: with SMTP id m11mr9162003ljg.213.1576834323858; Fri, 20 Dec 2019 01:32:03 -0800 (PST) Received: from xi.terra (c-14b8e655.07-184-6d6c6d4.bbcust.telenor.se. [85.230.184.20]) by smtp.gmail.com with ESMTPSA id z7sm4437120lfa.81.2019.12.20.01.32.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2019 01:32:03 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.92.3) (envelope-from ) id 1iiEde-0000L0-4r; Fri, 20 Dec 2019 10:32:02 +0100 From: Johan Hovold To: Takashi Iwai Cc: Jaroslav Kysela , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Johan Hovold , stable Subject: [PATCH] ALSA: usb-audio: fix set_format altsetting sanity check Date: Fri, 20 Dec 2019 10:31:34 +0100 Message-Id: <20191220093134.1248-1-johan@kernel.org> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make sure to check the return value of usb_altnum_to_altsetting() to avoid dereferencing a NULL pointer when the requested alternate settings is missing. The format altsetting number may come from a quirk table and there does not seem to be any other validation of it (the corresponding index is checked however). Fixes: b099b9693d23 ("ALSA: usb-audio: Avoid superfluous usb_set_interface() calls") Cc: stable # 4.18 Signed-off-by: Johan Hovold --- sound/usb/pcm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 9c8930bb00c8..73dd9d21bb42 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -506,9 +506,9 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt) if (WARN_ON(!iface)) return -EINVAL; alts = usb_altnum_to_altsetting(iface, fmt->altsetting); - altsd = get_iface_desc(alts); - if (WARN_ON(altsd->bAlternateSetting != fmt->altsetting)) + if (WARN_ON(!alts)) return -EINVAL; + altsd = get_iface_desc(alts); if (fmt == subs->cur_audiofmt) return 0; -- 2.24.1