From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDE69C433FF for ; Wed, 14 Aug 2019 17:02:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8F21C214DA for ; Wed, 14 Aug 2019 17:02:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802167; bh=VbVUEMkijF2O/rOpY1MxHf2BT9Hrorg4NIqbs8l1EXU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=HZJ8CAs4QXsXJlsfWA9EVPPq21NUd2m9xcv4Xa6LJaftdWEEbpTSo+qYcOV4K86vM 1oO7LNYBdRq7T1s/k6+gPBhckkOYGLeM0O1TuICozyXdWlWB3MhHbAHUSs35xdC398 zgSGgQ/kM2vcaDtGL/1mh+vw7Mn5ke9e+m18MXA4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728738AbfHNRCq (ORCPT ); Wed, 14 Aug 2019 13:02:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:51212 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728692AbfHNRCn (ORCPT ); Wed, 14 Aug 2019 13:02:43 -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 E2E5A214DA; Wed, 14 Aug 2019 17:02:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802163; bh=VbVUEMkijF2O/rOpY1MxHf2BT9Hrorg4NIqbs8l1EXU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b6GX0F7AxZ56CVQPzwXg/oTbvWWgu99E/wcNeetnWIwHKEKJ+E+31BgkYnDfaOBQJ qxWUgSBkX66iG/HsAYojHuPejCDzuckucU26nbPaHRz4XwbUzSwlFMzV0NP/Ylb+K1 IYmjQ7W6FHwEEVwvxCw+zRCc44GjAj8V+OjJEce8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wenwen Wang , Takashi Iwai Subject: [PATCH 5.2 019/144] sound: fix a memory leak bug Date: Wed, 14 Aug 2019 18:59:35 +0200 Message-Id: <20190814165800.678115911@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165759.466811854@linuxfoundation.org> References: <20190814165759.466811854@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 @@ -275,7 +275,8 @@ retry: goto retry; } spin_unlock(&sound_loader_lock); - return -EBUSY; + r = -EBUSY; + goto fail; } }