Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4645679ybl; Wed, 22 Jan 2020 01:58:44 -0800 (PST) X-Google-Smtp-Source: APXvYqw5OFCbBuyOVShyj73gxAqe4X1jedUYqSgO+zejA1U2PJlAH3CNIkYu1ydoBJK8IhQoqazH X-Received: by 2002:a05:6830:1294:: with SMTP id z20mr6757497otp.60.1579687124265; Wed, 22 Jan 2020 01:58:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579687124; cv=none; d=google.com; s=arc-20160816; b=uIUS/79Mk9EqTRztG0fguwry4eZfV46LLp61owj8zz3gqEO2+i4Fj4ELeQ/43pB7uu x4osZ+6HV+NtpQ0Az3QZJcBidhSvT9s//o44mXCcL0VZbt6Dw5u+JOjcCDeY8JNqRIiw yuPz6akL61Kz8rZm+42fyhYN7z0QXAuUCIh10aq5RQGztE/zpSUZr8NoFhIlYABIXm8o yDzLTdInTWz7TEtXP7z3Y3z2ZZQTuY1se4DLWYDQYG53nvM0ikihS2ALmVjnO+MH3iqs ICH6PjrPNQyWdEiclil1eZxkTNe+H+8EPl5rnflvFtrv/ink+WTkKgtG6PQ+ImbpdCzx 2zGQ== 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=0uKcJI9/IqJXK7bnXRXQ/sH9lioRQ2z7CMBFHMdNeic=; b=xpzhpHfWqg0sJ+2u5EDPgTTe1Z43AfVplPmvd1FJ/kXl5X+KyPSI/R/fQDxun9tlzr aKjQpf+JNphVeCg7HXpGHDHF7iAe8eRwzrMo24E3fHBaRMLnkFfrNU2cNL4rVOOB64vE TMkSz+5xOlY5Ruy3Jrf3cFY2z42v1+Cn8zSfp0l7Cg8bJf7Eat0XVK+2MGX9Pg/qNDdS Icczy2uBnksAGcj+BBAerUThBk9yBg9TQDXPKIr7KCs2njZGN8KQpNIxAXUJoqrdiN+S 2nhER/tDBfKfbcpcn3b4E3KsrakgXaTlf3nsfvY9+HaMEafNeGEUshFN5BjHGxCFcYVI vSRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lPk81BVS; 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 a64si21560771oif.256.2020.01.22.01.58.32; Wed, 22 Jan 2020 01:58:44 -0800 (PST) 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=lPk81BVS; 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 S1728609AbgAVJa1 (ORCPT + 99 others); Wed, 22 Jan 2020 04:30:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:41806 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726077AbgAVJa1 (ORCPT ); Wed, 22 Jan 2020 04:30:27 -0500 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 341EE24672; Wed, 22 Jan 2020 09:30:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579685426; bh=Oogjn1641qqnsLaIbsL6+IzoJpqGsW+vBvF7sxRiUBY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lPk81BVSjkRyoyXsVRz8maMfckaPsA7DzfZuD7cNlFNuEQwJxMXCsAB3efUGinmuD Th2Cqof37kwbuwjJzg6u1smxu5f3W/94uekhNZMI14Dbz9V6AaHWsDz+fiB3ok3SZX Oq/0xw0UQlHIJ2k9yozi3FriaDYMcf5YrhfP/b2M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai , Ben Hutchings Subject: [PATCH 4.4 10/76] ALSA: line6: Fix memory leak at line6_init_pcm() error path Date: Wed, 22 Jan 2020 10:28:26 +0100 Message-Id: <20200122092752.571103099@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200122092751.587775548@linuxfoundation.org> References: <20200122092751.587775548@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") Signed-off-by: Takashi Iwai [bwh: Backported to 4.4: adjust context] Signed-off-by: Ben Hutchings 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 @@ -523,6 +523,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; + /* Read and write buffers are sized identically, so choose minimum */ line6pcm->max_packet_size = min( usb_maxpacket(line6->usbdev, @@ -535,15 +544,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;