From patchwork Tue Aug 6 07:00:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenwen Wang X-Patchwork-Id: 11078755 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5CEC81398 for ; Tue, 6 Aug 2019 12:27:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A49928900 for ; Tue, 6 Aug 2019 12:27:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3EA2D28925; Tue, 6 Aug 2019 12:27:22 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 829CD2890C for ; Tue, 6 Aug 2019 12:27:21 +0000 (UTC) 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 73E9B165D; Tue, 6 Aug 2019 09:01:12 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 73E9B165D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1565074922; bh=VpI3JwBpVYlQN5MKxl8eHGdvuLpshNldU+YIxTq1OKs=; h=From:Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=jFB4Sz+9qRKDfu3em31g5+M50NX8iyPoDIlMTufx954x6Widn7Q94eLf29M7xAVyn 4BXtysnEsy9mKT6aYEomVdyNifg2gbMYsGEOGzZXiUW35+EwctXxuwJ1jLvJC0MOsK BknpmPiJ/GIl/nmK54WR0CieoIYLqACzBgFy4sD0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 07024F80290; Tue, 6 Aug 2019 09:01:12 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 89226F80483; Tue, 6 Aug 2019 09:01:10 +0200 (CEST) Received: from ajax.cs.uga.edu (ajax.cs.uga.edu [128.192.4.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5778CF800F3 for ; Tue, 6 Aug 2019 09:01:06 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5778CF800F3 Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (authenticated bits=0) by ajax.cs.uga.edu (8.14.4/8.14.4) with ESMTP id x76713uG032291 (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 6 Aug 2019 03:01:05 -0400 Received: by mail-lf1-f54.google.com with SMTP id s19so60141179lfb.9 for ; Tue, 06 Aug 2019 00:01:04 -0700 (PDT) X-Gm-Message-State: APjAAAVdH29Md2SS1UoW5m56X2QKsYk8cqhGRtmSjza83+I64RiTnidU 1hhEYU9VbHyvWG+K3A7QoRAKLMnbYzS1hepJblU= X-Google-Smtp-Source: APXvYqzK+h1zd05B5faJWK4k6lnbLwPVygF0Bc2bfH0WYGAZDBEe12r9ifxxD8N9NgISRwr6acMQCGJE4l4x2+UVOtA= X-Received: by 2002:a19:cbc4:: with SMTP id b187mr1253490lfg.27.1565074863147; Tue, 06 Aug 2019 00:01:03 -0700 (PDT) MIME-Version: 1.0 From: Wenwen Wang Date: Tue, 6 Aug 2019 03:00:27 -0400 X-Gmail-Original-Message-ID: Message-ID: To: Wenwen Wang Cc: "moderated list:SOUND" , open list , Takashi Iwai , Richard Fontana , Hans Verkuil , Thomas Gleixner , Shuah Khan Subject: [alsa-devel] [PATCH] ALSA: usb-audio: fix a memory leak bug 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP In snd_usb_get_audioformat_uac3(), a structure for channel maps 'chmap' is allocated through kzalloc() before the execution goto 'found_clock'. However, this structure is not deallocated if the memory allocation for 'pd' fails, leading to a memory leak bug. To fix the above issue, free 'fp->chmap' before returning NULL. Signed-off-by: Wenwen Wang --- sound/usb/stream.c | 1 + 1 file changed, 1 insertion(+) -- 2.7.4 diff --git a/sound/usb/stream.c b/sound/usb/stream.c index 7ee9d17..e852c7f 100644 --- a/sound/usb/stream.c +++ b/sound/usb/stream.c @@ -1043,6 +1043,7 @@ snd_usb_get_audioformat_uac3(struct snd_usb_audio *chip, pd = kzalloc(sizeof(*pd), GFP_KERNEL); if (!pd) { + kfree(fp->chmap); kfree(fp->rate_table); kfree(fp); return NULL;