From patchwork Wed Aug 7 03:22:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenwen Wang X-Patchwork-Id: 11080947 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 752E414DB for ; Wed, 7 Aug 2019 03:23:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5FCAD2894E for ; Wed, 7 Aug 2019 03:23:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 51B7B28961; Wed, 7 Aug 2019 03:23:49 +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 0437D2894E for ; Wed, 7 Aug 2019 03:23:47 +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 48CA183B; Wed, 7 Aug 2019 05:22:55 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 48CA183B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1565148225; bh=7nMihNHho8ir+6mp3Ci5S/F65R3NOLUZLD9zLn6Awp8=; h=From:Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=kNBl4pcmi5pOb7z2eVhkvvXgntkRnInyW4Y7VB3aoqj2gbtp5qxFnXcdXeST7iV/I tKDBn3VD5pvSMGTH/5H/HhyIbZjXVWrUfSTYNY+K6uXBIkP0JNJaDtk1SBYlZd2/6Z pjwZ6QPVZf8fbZwpjp6nMTYPYUNpDUTtQHn7JN9Q= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id CDC22F80290; Wed, 7 Aug 2019 05:22:54 +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 1E3BDF804CA; Wed, 7 Aug 2019 05:22:53 +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 49594F800F4 for ; Wed, 7 Aug 2019 05:22:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 49594F800F4 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (authenticated bits=0) by ajax.cs.uga.edu (8.14.4/8.14.4) with ESMTP id x773MjhW057165 (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 6 Aug 2019 23:22:47 -0400 Received: by mail-lf1-f47.google.com with SMTP id b29so55632554lfq.1 for ; Tue, 06 Aug 2019 20:22:46 -0700 (PDT) X-Gm-Message-State: APjAAAVvwIahdO4XYCwk5CO/7Frs0Sgu42gkdeEFqnWHqf5WH6DagMyP zdxedUalzHMSNfuzCa/eavRFM1Dv1LRkUnxmL5M= X-Google-Smtp-Source: APXvYqw3KascRBJeThGdIl1eMlrfY0MLn4+tPhdJYMi19pdSHHihKN0uMyQrgJJQBMdEzA/lLNkO+DuQuoIITtTaakI= X-Received: by 2002:ac2:442f:: with SMTP id w15mr4617610lfl.9.1565148165415; Tue, 06 Aug 2019 20:22:45 -0700 (PDT) MIME-Version: 1.0 From: Wenwen Wang Date: Tue, 6 Aug 2019 23:22:09 -0400 X-Gmail-Original-Message-ID: Message-ID: To: Wenwen Wang Cc: open list , "moderated list:SOUND" , Clemens Ladisch , Takashi Iwai Subject: [alsa-devel] [PATCH] ALSA: usb-midi: 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_usbmidi_create(), a MIDI streaming interface structure is allocated through kzalloc() and the pointer is saved to 'umidi'. Later on, the endpoint structures are created by invoking snd_usbmidi_create_endpoints_midiman() or snd_usbmidi_create_endpoints(), depending on the type of the audio quirk type. However, if the creation fails, the allocated 'umidi' is not deallocated, leading to a memory leak bug. To fix the above issue, free 'umidi' before returning the error. Signed-off-by: Wenwen Wang --- sound/usb/midi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/usb/midi.c b/sound/usb/midi.c index b737f0e..22db37f 100644 --- a/sound/usb/midi.c +++ b/sound/usb/midi.c @@ -2476,7 +2476,7 @@ int __snd_usbmidi_create(struct snd_card *card, else err = snd_usbmidi_create_endpoints(umidi, endpoints); if (err < 0) - goto exit; + goto free_midi; usb_autopm_get_interface_no_resume(umidi->iface);