Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp4893497ybh; Tue, 6 Aug 2019 20:25:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqwhXZPsPqDn0Yf8POBvKCb9PUBOBB0/2n9y3mWqKRR/ViOxuYkxFis9yIko6rjdbv/gvn1C X-Received: by 2002:a17:902:be0a:: with SMTP id r10mr5857090pls.51.1565148312085; Tue, 06 Aug 2019 20:25:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565148312; cv=none; d=google.com; s=arc-20160816; b=1LINgzm/bbZq/JsmIHqEQgQBrJ+sIubN/MDXKZ/+OS724tNQUT6Oflxi1xT4HT9P5O DFVzy45+HDuVuudtDbB1oOBUv/tdcFXlJqOUhAa3yudaIEXjmrmL09eqm6VfcAmpQxFn 11GJh+JEImMBBT8wQy9kwF6/HhrdQaCD6mAZp6da+vO6MQuIus3APefz/V2t5002xaWv AVUmB9qAmtMFQWSV2Trf2lYniuViTViN6AkVhIRxf+0HAPUWwuvxdcgIfQLImJVyi3Vq AgGkgX1VbBu97gEuHz4uUB80mDa+Mhu+6fzQCn049AkYS/AVpbwwDAc39rmZR2ALp8YK RB8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :mime-version; bh=ETLLr/momBimN6fM7eDE6+Ac6sqYQoODZoD87thaoTU=; b=tStTrum0K/7B0lY+5tm6v2gbsCqlAJgXnDt6++FC2WNdQ6Y5IzcXHssCO7n75STX8p 3c+/5BHrAWho3DbyMK6gpkwEiV86Yton1UTM5HnKMu7pLWv7bhosXwViJVXm+EetAI5Y f8B8XgGsLhN5fRunfQ7yLBDeU4QKXI6fRZrsQvrBzItaoNKESF0AGu2NVSmiJCQlH3f+ 3ekHfSpWJAJLuRll1tI87a4vkbL3hwoCsMhKo6UXuRQrcMWOmEgCaNhujiBgtV5B7DTa RR0pZay6KPNrL0KE30s+SNr8rTbBZQkeZIBljE/tzVLnK/BTIxUT/16WqGNx8VbrSYnN da4w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id co12si44351919plb.197.2019.08.06.20.24.55; Tue, 06 Aug 2019 20:25:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728267AbfHGDWs (ORCPT + 99 others); Tue, 6 Aug 2019 23:22:48 -0400 Received: from ajax.cs.uga.edu ([128.192.4.6]:43394 "EHLO ajax.cs.uga.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726334AbfHGDWs (ORCPT ); Tue, 6 Aug 2019 23:22:48 -0400 Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (authenticated bits=0) by ajax.cs.uga.edu (8.14.4/8.14.4) with ESMTP id x773MjL1057164 (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 6 Aug 2019 23:22:46 -0400 Received: by mail-lf1-f41.google.com with SMTP id c19so62874256lfm.10 for ; Tue, 06 Aug 2019 20:22:46 -0700 (PDT) X-Gm-Message-State: APjAAAV5BbwZnQEzqrmdgbllVBfcfBXhkNn9ebln8bz5MBcrSoy/JTJC L3kxHMEN7Bh2zuYw14BxIvdd/kkMf/0UCfGbfIM= 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: Subject: [PATCH] ALSA: usb-midi: fix a memory leak bug To: Wenwen Wang Cc: Clemens Ladisch , Jaroslav Kysela , Takashi Iwai , "moderated list:SOUND" , open list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.7.4