Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1076856ybl; Wed, 14 Aug 2019 10:19:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqyBPWOsVbjIAls0lBeq2MNpQxagXAGYZrS9u2E6wWVNWQaepIqLGhD5jHkiApIpSoiozV4r X-Received: by 2002:a63:eb51:: with SMTP id b17mr219357pgk.384.1565803142089; Wed, 14 Aug 2019 10:19:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565803142; cv=none; d=google.com; s=arc-20160816; b=KY9pGALUwE+AP97dhjEdYo1tS2WIH/Zonp13bLtRZKRx+5jeBRPsUFmgRvpS5uB9kb /lvd3li1UK2jAYQHrx8syx6ZLMz+4oicww/yeF7wICaNSO9Gie5gTb6NwzXmAMEo4wxD BWsg0ZIJoxJlnN78+IeQ6IdkR+PNhHwdOZT9tODlAYm30VjCcuIkIlsa9WvQcg26WaDI g8DceJPOgIyNdtbH0quRuomJlNGPNplOnNojGGmE75ri6gn/AcZYlbl/v7OeIvaKJKcJ VqOC0vwU1su8N81n2G7KS/u1LWsvzq4jmLoqnECS2aeQ68NFhFdWpmohr/8xIeNwFnp9 nREg== 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=SuIZBQ637V3HUu2YkXSSzT0piWbIMlqnbPZqW0fD98xsFb/gESlV51mGwRKR8La5PW UTPzvOsf5czOiDCqdkpGznd5JyXxK+z6esemMbLzNTKXKiyeFq5jQJ/KLOD8iP75RXLk O++3l33sqBpXfY8JcyyKT7Ul4tl8rtz7wTb8JdO+0EwwdoDPXOoPorhAdyvRioHZcA2V Tvz4VWPvlyK0nieWo9KsANgvtnNRQtRL3bzDLTEk9XUyO6uYnigzLZVaAxuMAFVr7Wym qDIw2aRB7NY1snTweVVXga1ipsgaKDvHuWGPIQGu4CYHc+vp6qfIWlGB1no/CD2aN9w4 jykw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EYgn5H55; 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 t185si191619pgb.329.2019.08.14.10.18.46; Wed, 14 Aug 2019 10:19:02 -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=EYgn5H55; 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 S1730784AbfHNRMp (ORCPT + 99 others); Wed, 14 Aug 2019 13:12:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:36688 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730781AbfHNRMm (ORCPT ); Wed, 14 Aug 2019 13:12:42 -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 4347B2084D; Wed, 14 Aug 2019 17:12:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802761; bh=Mh1/bHNMSZxjSXWuCew94BhzmXBwks+dNsCioYr3Aqg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EYgn5H55CrutH8ZPMDxGWKt+xm3nxBs06ejfeBzNAPbNPPh+IHHxhoo68DW4Vf0X3 Q0crLLldBDPs78PQl3+HlIK7mhEb65AykAprJS8uADpmqbVcAfg7R0WsVtlcJvS/2V wfm5NUGURRx8TCcgCeEgjj6/LXdtIt5K09/KSeZw= 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.14 06/69] sound: fix a memory leak bug Date: Wed, 14 Aug 2019 19:01:04 +0200 Message-Id: <20190814165745.758139241@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165744.822314328@linuxfoundation.org> References: <20190814165744.822314328@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; } }