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=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 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 ACC16C47083 for ; Wed, 2 Jun 2021 06:47:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7B22B6139A for ; Wed, 2 Jun 2021 06:47:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229905AbhFBGs5 (ORCPT ); Wed, 2 Jun 2021 02:48:57 -0400 Received: from mail1.perex.cz ([77.48.224.245]:36674 "EHLO mail1.perex.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229742AbhFBGsz (ORCPT ); Wed, 2 Jun 2021 02:48:55 -0400 Received: from mail1.perex.cz (localhost [127.0.0.1]) by smtp1.perex.cz (Perex's E-mail Delivery System) with ESMTP id 9B59FA003F; Wed, 2 Jun 2021 08:47:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.perex.cz 9B59FA003F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=perex.cz; s=default; t=1622616430; bh=9oZydlE7ZvsDH6T9qh0iMZKszEstZjjcoeV/i59z/mE=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=M2C6beweJKaC2OtGnhH8ZlHfEitgurkfioMrWGLO3yHZrVOeHi0nDavbWPLAIzGaF kdMhKP9KO5i1XnOua7KzrGJpqA0cS2i5AozuSx59u1uu/+rPfZJWztqlKKzVhouRQT vr23yqiL0CihyZawpR6EH90q0w/AAiov7hiBiNsY= Received: from p1gen2.localdomain (unknown [192.168.100.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: perex) by mail1.perex.cz (Perex's E-mail Delivery System) with ESMTPSA; Wed, 2 Jun 2021 08:47:04 +0200 (CEST) Subject: Re: [PATCH v2] ALSA: control led: fix memory leak in snd_ctl_led_register To: Dongliang Mu , tiwai@suse.com, dan.carpenter@oracle.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Cc: syzbot+08a7d8b51ea048a74ffb@syzkaller.appspotmail.com References: <20210602034136.2762497-1-mudongliangabcd@gmail.com> From: Jaroslav Kysela Message-ID: <1032c823-90aa-0144-eb7a-ff1a019c3094@perex.cz> Date: Wed, 2 Jun 2021 08:47:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210602034136.2762497-1-mudongliangabcd@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02. 06. 21 5:41, Dongliang Mu wrote: > The snd_ctl_led_sysfs_add and snd_ctl_led_sysfs_remove should contain > the refcount operations in pair. However, snd_ctl_led_sysfs_remove fails > to decrease the refcount to zero, which causes device_release never to > be invoked. This leads to memory leak to some resources, like struct > device_private. In addition, we also free some other similar memory > leaks in snd_ctl_led_init/snd_ctl_led_exit. > > Fix this by replacing device_del to device_unregister > in snd_ctl_led_sysfs_remove/snd_ctl_led_init/snd_ctl_led_exit. > > Note that, when CONFIG_DEBUG_KOBJECT_RELEASE is enabled, put_device will > call kobject_release and delay the release of kobject, which will cause > use-after-free when the memory backing the kobject is freed at once. > > Reported-by: syzbot+08a7d8b51ea048a74ffb@syzkaller.appspotmail.com > Fixes: a135dfb5de1 ("ALSA: led control - add sysfs kcontrol LED marking layer") > Signed-off-by: Dongliang Mu Many thanks to you and Dan to cover this. Revieved-by: Jaroslav Kysela -- Jaroslav Kysela Linux Sound Maintainer; ALSA Project; Red Hat, Inc.