From patchwork Wed Aug 19 07:28:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Scheel X-Patchwork-Id: 7035901 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1E9C29F372 for ; Wed, 19 Aug 2015 07:29:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1D54F20873 for ; Wed, 19 Aug 2015 07:29:15 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 68A89203F1 for ; Wed, 19 Aug 2015 07:29:13 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 588D2265015; Wed, 19 Aug 2015 09:29:12 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, RCVD_IN_DNSWL_LOW,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id B85AF261B2A; Wed, 19 Aug 2015 09:28:32 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 80125261B2A; Wed, 19 Aug 2015 09:28:31 +0200 (CEST) Received: from sender163-mail.zoho.com (sender163-mail.zoho.com [74.201.84.163]) by alsa0.perex.cz (Postfix) with ESMTP id EB4F2261B36 for ; Wed, 19 Aug 2015 09:28:21 +0200 (CEST) Received: from juli-workstation.adnet.avionic-design.de (x2f1187f.dyn.telefonica.de [2.241.24.127]) by mx.zohomail.com with SMTPS id 1439969299044894.4084247457936; Wed, 19 Aug 2015 00:28:19 -0700 (PDT) From: Julian Scheel To: daniel@zonque.org, tiwai@suse.de, alsa-devel@alsa-project.org Date: Wed, 19 Aug 2015 09:28:09 +0200 Message-Id: <1439969289-25357-1-git-send-email-julian@jusst.de> X-Mailer: git-send-email 2.5.0 X-ZohoMail: Ss SS_10 UW UB CHF_INT_SMD_EXT SGR4_1_11085_0 X-ZohoMail-Owner: <1439969289-25357-1-git-send-email-julian@jusst.de>+zmo_0_ X-ZohoMail-Sender: 2.241.24.127 X-Zoho-Virus-Status: 2 Cc: Julian Scheel Subject: [alsa-devel] [PATCH v2] ALSA: usb-audio: Recurse before saving terminal properties X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP The input terminal parser recurses into the referenced clock entity to verify it is existant and thus the terminal descriptor is valid. The actual property values of the term instance which is initially parsed must not be overriden by the recursion. For this to work the term properties have to be assigned after recursing into the referenced clock entity descriptors. Signed-off-by: Julian Scheel Acked-by: Daniel Mack --- Changes in v2: - Store term->id after recursion as well, as it gets overriden in the recursion - Add comments explaining that the recursion is only for validation of the descriptor validity --- sound/usb/mixer.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 81055d3..c50790c 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -731,15 +731,21 @@ static int check_input_term(struct mixer_build *state, int id, term->name = d->iTerminal; } else { /* UAC_VERSION_2 */ struct uac2_input_terminal_descriptor *d = p1; - term->type = le16_to_cpu(d->wTerminalType); - term->channels = d->bNrChannels; - term->chconfig = le32_to_cpu(d->bmChannelConfig); - term->name = d->iTerminal; - /* call recursively to get the clock selectors */ + /* call recursively to verify that the + * referenced clock entity is valid */ err = check_input_term(state, d->bCSourceID, term); if (err < 0) return err; + + /* save input term properties after recursion, + * to ensure they are not overriden by the + * recursion calls */ + term->id = id; + term->type = le16_to_cpu(d->wTerminalType); + term->channels = d->bNrChannels; + term->chconfig = le32_to_cpu(d->bmChannelConfig); + term->name = d->iTerminal; } return 0; case UAC_FEATURE_UNIT: {