From patchwork Thu May 17 22:08:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruslan Bilovol X-Patchwork-Id: 10407805 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A1B2560353 for ; Thu, 17 May 2018 22:17:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82E92287AE for ; Thu, 17 May 2018 22:17:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7303A287B5; Thu, 17 May 2018 22:17:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A982A287AE for ; Thu, 17 May 2018 22:17:16 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id EB03A267045; Fri, 18 May 2018 00:10:12 +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 6682A26707F; Fri, 18 May 2018 00:10:10 +0200 (CEST) Received: from mail-lf0-f67.google.com (mail-lf0-f67.google.com [209.85.215.67]) by alsa0.perex.cz (Postfix) with ESMTP id BF27E266F44 for ; Fri, 18 May 2018 00:10:07 +0200 (CEST) Received: by mail-lf0-f67.google.com with SMTP id h9-v6so11031699lfi.0 for ; Thu, 17 May 2018 15:10:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=4MFqtGovvhEXU/Fb8ZsAjEUiYDecpgag7HpG70tCneo=; b=kT1z/TdzCAkN5xPkjQB5wSW1wIL21A3zVDLc2OqZKvFCyB+qx/yO/FsC4qWAWPMPOX RH0CC4Dsdbm0EoqFSEeUHO+hlgjfuAB3oTREL4Ic3AOCpL06Xu0A3D3GVwsuX0dqpffN mbYH6L7c9rfJD7Umw/5oAf0/zdGx3sJ65/HMBtUdr5yiqT6Xrm2D0ZBDTnXIyIKx5RNz txU/kwbgKJMOYrACn9JeOrIcG8ff+3HDAK0dreJrLMMrlkKlZKfTkSWQEuIk3StDEUiD 8lfuz3J9kX/FcsS9W1L70+Wj5DvBc1s4LYq6EP86Hc1wSfrxa4/oJrr+mntoU2wPL2CQ Yq0w== 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; bh=4MFqtGovvhEXU/Fb8ZsAjEUiYDecpgag7HpG70tCneo=; b=rzIrro1jpGxC2MUUJgQWr2EMcIX4xLnofpaRazWqxo55TUYVnw1fB7KGklcQGMGBW6 wH13sBm0l5P6GCMcheSPU6PMtwS1szSVI42Aoo5l1yrnng4EwgWTtS8Jnwum1RPq9fIb B3g+WIQr3uUgGQ+uI+7v7xXQcIBe/HfDv1sWoQiCRBOvAIKYU16T8GiAVMx/Et93qMWe c3X19HweRJrfWIY+COPc2Jla56AeonfOUip96zlMfjAHMBbPGp8uaXp3PWGyljf17sYl u/lnmadPvImXRLmY4AalULe1CZQiKogIs6T1qCJE/X3jUe6rJ/y+nqOhUPktOWxWpM1X f/XQ== X-Gm-Message-State: ALKqPwfIhSj7CdPKk8AxC6VLT9gP1OC909GZwMDe8HYBcEWip7d5S95y dsDLXSNsEQwcZFT3ROCxpw0= X-Google-Smtp-Source: AB8JxZrPlFWmBKtQF6IWWHINrNeriIP3xhuyoZ3F/uRyjdZ7MEthiPt4WdhQ8/yYrce0tzTBp0eGkw== X-Received: by 2002:a19:5e4f:: with SMTP id z15-v6mr19816194lfi.129.1526595006850; Thu, 17 May 2018 15:10:06 -0700 (PDT) Received: from localhost ([62.216.63.1]) by smtp.gmail.com with ESMTPSA id e7-v6sm976635ljj.95.2018.05.17.15.10.05 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 17 May 2018 15:10:05 -0700 (PDT) From: Ruslan Bilovol To: Takashi Iwai Date: Fri, 18 May 2018 01:08:59 +0300 Message-Id: <1526594939-21084-1-git-send-email-ruslan.bilovol@gmail.com> X-Mailer: git-send-email 1.9.1 Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Dan Carpenter Subject: [alsa-devel] [PATCH] ALSA: usb: stream: fix potential memory leak during uac3 interface parsing 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 UAC3 channel map is created during interface parsing, and in some cases was not freed in failure paths. Reported-by: Dan Carpenter Signed-off-by: Ruslan Bilovol --- sound/usb/stream.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sound/usb/stream.c b/sound/usb/stream.c index bce3152..d16e1c2 100644 --- a/sound/usb/stream.c +++ b/sound/usb/stream.c @@ -982,13 +982,16 @@ static int parse_uac_endpoint_attributes(struct snd_usb_audio *chip, dev_err(&dev->dev, "%u:%d : bogus bTerminalLink %d\n", iface_no, altno, as->bTerminalLink); + kfree(chmap); return NULL; found_clock: fp = audio_format_alloc_init(chip, alts, UAC_VERSION_3, iface_no, altset_idx, altno, num_channels, clock); - if (!fp) + if (!fp) { + kfree(chmap); return ERR_PTR(-ENOMEM); + } fp->chmap = chmap; @@ -1009,6 +1012,7 @@ static int parse_uac_endpoint_attributes(struct snd_usb_audio *chip, iface_no); /* ok, let's parse further... */ if (snd_usb_parse_audio_format_v3(chip, fp, as, stream) < 0) { + kfree(fp->chmap); kfree(fp->rate_table); kfree(fp); return NULL;