Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1021940ybe; Wed, 4 Sep 2019 11:16:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqx1bVUuax4WSuyx0HO9c1d9+zkAqnUpmx5SqpOf7Gk0VO54d5tHzaPTFm1+hnWOppXgfP0R X-Received: by 2002:a17:902:a985:: with SMTP id bh5mr3564990plb.107.1567620979146; Wed, 04 Sep 2019 11:16:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567620979; cv=none; d=google.com; s=arc-20160816; b=pTFC9n31bCtEEpoGCUyI8Z2eMuM4BcW6HrdDs6cKotufLaozSU7N3xFmG2LjdbISHA SGILEJ4xvPJwYzQiNQg8aN5oeQk0Ja9GXKAhotmV9TnyCFHmJVjP/s3BBo2i/CdoSUD7 FWSmiBe1+VIFk5/scRjBfNSqSq6hcqfcTkSzAyJ3XbmK7jMKiVTfB/zEUMYNh2XsjQH4 tiQD4xlCB279/Csb1EBx7CaIQPX8cWhvgCBCj9Z9DpCp6L+E3O0obCHKTcj3e2VkMOPO VWF1jUGuarkUf2e/WU0M8gIBGZGUDIOfrZgxG68h026wQQJozFAdmm7KIofPXG4zMiGe AfXA== 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=R+DjmvlwPdN2100CQEi15O6PQ13DtgXscSe8jApjx9I=; b=v7nChmBP91JY3+wspfGAU1NvmqHBtbdmIxFSFR4nYa+gyZtNiAk0GOz14aRcdpUs+8 /ZRLvpXqXOxlxRjUZUoqyCzu2mDPp3VM3Eil2HCb32fG1JrpTxE8+Z2ofFLlOJSJM1G5 6skrnl1gszwB8pLY+4s7TU5+CbNujn4EN6L8k80qRpNQYYI8YPo2Oh1tOVrD5rQd/A// ODT0lmrPsu5UsI+cGRZEmijPYJpoKxNWheCniGGp6aAooT3NjXTMM0nQnSZrt71CYBs+ h43qmHUZRrhjIV2WxuAIzE8YmAFcEKevfOdGQ6ZRRzJm34h51qsZnBqBvn3/r0dtAMnn d8IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YH0YKlYc; 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 a7si10503788pfo.117.2019.09.04.11.16.04; Wed, 04 Sep 2019 11:16:19 -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=YH0YKlYc; 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 S2390699AbfIDSNb (ORCPT + 99 others); Wed, 4 Sep 2019 14:13:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:58364 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390694AbfIDSN3 (ORCPT ); Wed, 4 Sep 2019 14:13: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 6B057208E4; Wed, 4 Sep 2019 18:13:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567620808; bh=XpVMRruxLN1E2XX5gewbcsvYWzPngDOtSDaa0SDg7os=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YH0YKlYcxsY+5nsxOdkin2OTSdERyUtoNTWwuJycj5ark1YOK8D2ger4TbJL8ijY+ EE1/6Lw4Jei4c0a8yrFyHASKXOpiwoviVtMBwCEpdCboeIEnD2YSLP0zLL5vkbujdM zPRHQRFojN5Sj60YzLJ+m6P+wJl0EhYoJNzaA6II= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai Subject: [PATCH 5.2 062/143] ALSA: line6: Fix memory leak at line6_init_pcm() error path Date: Wed, 4 Sep 2019 19:53:25 +0200 Message-Id: <20190904175316.499042936@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190904175314.206239922@linuxfoundation.org> References: <20190904175314.206239922@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: Takashi Iwai commit 1bc8d18c75fef3b478dbdfef722aae09e2a9fde7 upstream. I forgot to release the allocated object at the early error path in line6_init_pcm(). For addressing it, slightly shuffle the code so that the PCM destructor (pcm->private_free) is assigned properly before all error paths. Fixes: 3450121997ce ("ALSA: line6: Fix write on zero-sized buffer") Cc: Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/usb/line6/pcm.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c @@ -550,6 +550,15 @@ int line6_init_pcm(struct usb_line6 *lin line6pcm->volume_monitor = 255; line6pcm->line6 = line6; + spin_lock_init(&line6pcm->out.lock); + spin_lock_init(&line6pcm->in.lock); + line6pcm->impulse_period = LINE6_IMPULSE_DEFAULT_PERIOD; + + line6->line6pcm = line6pcm; + + pcm->private_data = line6pcm; + pcm->private_free = line6_cleanup_pcm; + line6pcm->max_packet_size_in = usb_maxpacket(line6->usbdev, usb_rcvisocpipe(line6->usbdev, ep_read), 0); @@ -562,15 +571,6 @@ int line6_init_pcm(struct usb_line6 *lin return -EINVAL; } - spin_lock_init(&line6pcm->out.lock); - spin_lock_init(&line6pcm->in.lock); - line6pcm->impulse_period = LINE6_IMPULSE_DEFAULT_PERIOD; - - line6->line6pcm = line6pcm; - - pcm->private_data = line6pcm; - pcm->private_free = line6_cleanup_pcm; - err = line6_create_audio_out_urbs(line6pcm); if (err < 0) return err;