Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1069300ybl; Wed, 14 Aug 2019 10:12:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqyTMdcG1IeV7oBx74m4ON6RRKgwyuOmOjHt1forP1jMkXI06lQ13QamdmSab0QlseazuAVO X-Received: by 2002:a17:902:ba8e:: with SMTP id k14mr485453pls.10.1565802728149; Wed, 14 Aug 2019 10:12:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565802728; cv=none; d=google.com; s=arc-20160816; b=WpmP1Li8IsENm01E8ADRTpCvgccsR1fm/mfQT7x1kWCCT6SxaniEPtnMVzit8MIElD jYg3C7QJsjQfYGUsfDBw5eBJMgg9ux3ltNOZSe9qykJjj1QwMr6UJC7hq2AI2K9eqG26 CsTvs5fXLPJ9EGm043nSMSyaQw+r2DoU/hBuG0Hdpaj9fQcFPXknspGTU6NvO6ikJmU8 gFbQzC0IXs/UY8T559iTP2DOS2C++oLo/ZmqZw8EvIuNdSdvIXwExd+O13Pnagn3qo2B +paaF0KszEvr4b2pHYwmAnspqmJcusW5PIp+WVrx2Yulqp1Fy+kj80XBsELk0RqBMmDU lmqA== 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=w4TUCieO9j0jZg2qPyzHxwrbkMJk2JaVLobIk89+cDs=; b=qLiodyZgqsDAjcOyKucAjGckmr5y+fyZ3ZxNxW/tE5CnIQ3ut++zrsEWPMGQx1SWvF gmpw6wJzqBzc3GGtWjBRXRjkTszoKI7hVn6vu7A1cuiKCZErsUNvjHVJr/G/+oRq8O8/ YhTnwegUq0TGdMUPdmk+WOBWoRpTCYBh58LfSzzqgegTBQEfqXNcrDFD/VnrzJkuwv8g NhTk1lfnHRWb297uqNh3geZHbkoRIpsYQqbyK8xLJ3uC1dtATgXE05t29fZ6btLtLMHo hAzmTre4/IWDUJ2y0EwNxUPyTLLHbBLT65k6DbQ87n2cNNsfbmUWCXUMErh11xAwiwAg wXQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hzcobyzk; 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 f19si263365plr.91.2019.08.14.10.11.52; Wed, 14 Aug 2019 10:12:08 -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=hzcobyzk; 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 S1730394AbfHNRJw (ORCPT + 99 others); Wed, 14 Aug 2019 13:09:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:60358 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730391AbfHNRJs (ORCPT ); Wed, 14 Aug 2019 13:09:48 -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 2DA982084D; Wed, 14 Aug 2019 17:09:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802587; bh=Bdw0sl1aWne9A7zIwsKJUivc8ei5zDfDpTfnzUxJBYs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hzcobyzkANO3Kk4zLs8ygxP4qY/1mWorEWzLUu8voTxdFdi7SWLwSSzXlqmVevUFo 8u9WQgp5U1d43RLSZruJr4QyZXaaiJrk6S7VBYa3ARGDLqWXeG7xrCnk8yKhzQ9NBt 3jZfWuP4ZY//h3dumNJhg6m7jjiGnjUXfMkHg6o4= 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.19 10/91] sound: fix a memory leak bug Date: Wed, 14 Aug 2019 19:00:33 +0200 Message-Id: <20190814165750.046750688@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165748.991235624@linuxfoundation.org> References: <20190814165748.991235624@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 @@ -280,7 +280,8 @@ retry: goto retry; } spin_unlock(&sound_loader_lock); - return -EBUSY; + r = -EBUSY; + goto fail; } }