Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp240670ybl; Thu, 22 Aug 2019 23:39:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqwwRl0Tn8AvlA6dhl9ktQrZyh4S7bauI5CPOpl/P7ZF4Bym3KSRNPRRnaw2jnGlf1lyReou X-Received: by 2002:a17:90a:3b4f:: with SMTP id t15mr3691568pjf.45.1566542389194; Thu, 22 Aug 2019 23:39:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566542389; cv=none; d=google.com; s=arc-20160816; b=BMmfYXNIc4Kw2sNEDFTbZ3UDrESJpA05H6DfRsa93UcAVXrvUFkSnecOSci9rIar8Y peCUiUuCjvcuquA+gh+ntMLXO0IgGh7CdB8odpCS0qAQfLoxOi5KOuDnyq0CQK+P2nl3 oHTsaerKAcbM8TJ1a9YAUw+Bh7lcSIQs9JUHmZ+GFSKb08/qpMc1sDKYoJS/6Pz+OvN3 j074cFfNy1UXn+niupMNRnn4U3lWLkQ3uVdZLwWYijc57FEV9TVhpnm/kSwLC0VySLBK +pVf4ke7SmXJ3AcpRu1r7QrqrleluNsSMcHZlsEzm4Pp4eH4ObPhpgEuRWMZ5UFrV9oO Njng== 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=ihr8XfdeJkSEUzlSe32u+sIP99628tdINj+WPRQxAqc=; b=mDcypEzCVG+Gea1PBsNX0uadn3bk4N6n+MMUQ2I0iFc4KtyyHCcc4cwdIcT5axXSVg 4+tuJFRerwVh9Pg1b51CuC9XA7Jz+RzhjvVTj8lVbLzhNRLKnaXmVs0S6lKQ1GweBh7Z lUmnK12didx+CXvhAKmgAWpGgroUmYy19cNWvQ6/beiIy8UuJlfeAA/QcXCp+fy9ERe4 r5hDHBhPWKMu+dzBw/0WD6KXs4tAG+KLX0xqNVtmuWPyditfolMCLd0Prm7FK1gID0k8 Kv7UKS11AJ/JlaXiZbzo1mshuBz8Bcuc5vVltMAwDAhu79XF+o1EFOjVPeS8J07Kh43+ MxKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=p45DeVPg; 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 a10si1694239pff.277.2019.08.22.23.39.32; Thu, 22 Aug 2019 23:39:49 -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=p45DeVPg; 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 S2405366AbfHVRnk (ORCPT + 99 others); Thu, 22 Aug 2019 13:43:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:43374 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403952AbfHVRX1 (ORCPT ); Thu, 22 Aug 2019 13:23:27 -0400 Received: from localhost (wsip-184-188-36-2.sd.sd.cox.net [184.188.36.2]) (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 B23D823402; Thu, 22 Aug 2019 17:23:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566494606; bh=Mh1/bHNMSZxjSXWuCew94BhzmXBwks+dNsCioYr3Aqg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p45DeVPgnsbK1OL3M7JfnGKVXjNHe1Utfs9CqAuyoYoaHSKc+fh6sCeg4STvr+lqO FCNDEEN1DnSSqhcBGt+epB0ok4gHXOx+MwL3iikmCgCUgVWG0PRLnZxrqktTYQbcTJ 5paCWfm2dzIUSNoy1bzvAzz169dtICCgfF/v11+4= 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.9 003/103] sound: fix a memory leak bug Date: Thu, 22 Aug 2019 10:17:51 -0700 Message-Id: <20190822171728.674067039@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190822171728.445189830@linuxfoundation.org> References: <20190822171728.445189830@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 c7cd7c748a3250ca33509f9235efab9c803aca09 upstream. In sound_insert_unit(), the controlling structure 's' is allocated through kmalloc(). Then it is added to the sound driver list by invoking __sound_insert_unit(). Later on, if __register_chrdev() fails, 's' is removed from the list through __sound_remove_unit(). If 'index' is not less than 0, -EBUSY is returned to indicate the error. However, 's' is not deallocated on this execution path, leading to a memory leak bug. To fix the above issue, free 's' before -EBUSY is returned. Signed-off-by: Wenwen Wang Cc: Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/sound_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/sound/sound_core.c +++ b/sound/sound_core.c @@ -287,7 +287,8 @@ retry: goto retry; } spin_unlock(&sound_loader_lock); - return -EBUSY; + r = -EBUSY; + goto fail; } }