Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2415390ybi; Sun, 9 Jun 2019 11:11:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqzgIZ6tQllt7yQ5TdoXG05pLktNi3GQ8Q2YO2PuvVWGz2YxEepbaPDS1G1QCtdB+kaRhAy2 X-Received: by 2002:a17:902:70c4:: with SMTP id l4mr50530517plt.185.1560103891052; Sun, 09 Jun 2019 11:11:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560103891; cv=none; d=google.com; s=arc-20160816; b=jZNEyYoexcE7pR/AKzaa/uXNw9R3iX5fqlv+OLHuio5cIPvXjJmKf05fgLqJdjYvxZ Pt0rNTQN/NApyLESM1O26GS88slD8DzfGA7Fl2BeoC4n8JDuX8iXV3fdcllcZZzfQRZJ ymjvHd7/qJDUeBwCz5ZP/mRWh/VqwAYWsWcznLrOUptNaZGcEpB3fid85DN5pfMD+5/M 9TKroa5DxlVLnOCwjBENDDMtx16a46+5Ilpdf5LXF1Okzu+v0k3NefMLqty0yScBBRSI Kgo6wW3g6SpFckI9hUu3AlqjC+kJvl6rm0MC4cWw3DGl4SWA0BWGLxS3nBvBGzn+Md9x HGWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=syTn8vWJP7JiB2LMXZjIKEhnRqmAzihlDsrF9/GrcLk=; b=KD/hxwDosTyxWVV2pLkH25bQhI3b3qDWNz7u8FkSF+oPRrCgnHTTWxZ8AB63aQ+mlN 8A2yz+qRpE9bNhYfVIbrhxMxvX+QHU8yuTxIbQHrqPn0MXVSXYUcEKvwmQKo0ZGrqwHS WRTgCryFN/irtUg5Bjq0v3J3iK1i8kFfamtE2y0gOFvTN2mUIusdfEKE37IG2b7oFaPp VSqsM2IvqQVawv4ZXKi+eZiD8RhgXU41Pp2oBqmotBvqKfiFMBMrFJl/7OD5rtwgP+u/ pp5pQ0KfKzEesUOz5SUYPD6pMA9xhZ/eCKR4UfPu50SEPLQbQ8Sz0xcY4ooHllH8H1nM dyrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gN1JOwo4; 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 k23si7451661pgi.86.2019.06.09.11.11.14; Sun, 09 Jun 2019 11:11:31 -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; dkim=pass header.i=@kernel.org header.s=default header.b=gN1JOwo4; 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 S1732997AbfFIQ4c (ORCPT + 99 others); Sun, 9 Jun 2019 12:56:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:59028 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732987AbfFIQ43 (ORCPT ); Sun, 9 Jun 2019 12:56:29 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2978C206DF; Sun, 9 Jun 2019 16:56:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560099388; bh=gVTEveb/aumh0iU0IEwtM0Zuf7f6w6/4SFOhMCJm8lk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gN1JOwo4WBSvDVfRspXbtA+8HEA3/t/bdZlPOA7GvwjAJTQJk62nFO9GCFLEbPxmx cvCAXLuHO75O0jrqI+BfPazEjZoXJhKlKbPIUQoEixNqjGJqwt6Q5T1yWIjzNcQpPx Unr7lm/g/fnX9SyzgaE3jC6RqneGcec2lQThkeig= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wenwen Wang , Takashi Iwai Subject: [PATCH 4.4 007/241] ALSA: usb-audio: Fix a memory leak bug Date: Sun, 9 Jun 2019 18:39:09 +0200 Message-Id: <20190609164147.999654229@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190609164147.729157653@linuxfoundation.org> References: <20190609164147.729157653@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wenwen Wang commit cb5173594d50c72b7bfa14113dfc5084b4d2f726 upstream. In parse_audio_selector_unit(), the string array 'namelist' is allocated through kmalloc_array(), and each string pointer in this array, i.e., 'namelist[]', is allocated through kmalloc() in the following for loop. Then, a control instance 'kctl' is created by invoking snd_ctl_new1(). If an error occurs during the creation process, the string array 'namelist', including all string pointers in the array 'namelist[]', should be freed, before the error code ENOMEM is returned. However, the current code does not free 'namelist[]', resulting in memory leaks. To fix the above issue, free all string pointers 'namelist[]' in a loop. Signed-off-by: Wenwen Wang Cc: Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/usb/mixer.c | 2 ++ 1 file changed, 2 insertions(+) --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -2112,6 +2112,8 @@ static int parse_audio_selector_unit(str kctl = snd_ctl_new1(&mixer_selectunit_ctl, cval); if (! kctl) { usb_audio_err(state->chip, "cannot malloc kcontrol\n"); + for (i = 0; i < desc->bNrInPins; i++) + kfree(namelist[i]); kfree(namelist); kfree(cval); return -ENOMEM;