From patchwork Sun Apr 4 06:40:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 415168 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 1C211C433ED for ; Sun, 4 Apr 2021 06:41:46 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6E88061278 for ; Sun, 4 Apr 2021 06:41:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6E88061278 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 17C7C16B4; Sun, 4 Apr 2021 08:40:52 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 17C7C16B4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1617518502; bh=CvY/aveMKXvv2ZNGtaC9biIFy0i/CVgmBpAjC9aYB3Q=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=cN8edk9zI1s32RZHhgcwjpb5WrIIAaIW8YYDbIMpc1Mtm1paRX6e5F5/AQUKqSDlq TxfqmFgrXL1nFmjuAlRhd+ahRnpEGENaeWUXtWoq06ki7U+jKnU1pNLf6iq45LrfsM i5usq4od2+93do0203oiOx8aKXSTnvGHfxcyVRdQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 95C6BF80168; Sun, 4 Apr 2021 08:40:51 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 26EC2F8020B; Sun, 4 Apr 2021 08:40:50 +0200 (CEST) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 898BFF800F3 for ; Sun, 4 Apr 2021 08:40:40 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 898BFF800F3 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="3Y4E/u2P"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="ITnz5dx8" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 3F7BF139C; Sun, 4 Apr 2021 02:40:37 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 04 Apr 2021 02:40:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm1; bh=xJNreNlX7zIJlO8+DgDL6ZCtvY TVVTVGIzioKxhItXA=; b=3Y4E/u2PSjhK8aI+zcnHQ/XYwgHlBr/o8Bdeag/Bio YUoGA8rIk60uLExifJOEWaPxij1QiwegxY14NIF3Uhumsf2/FuCPM2wt+Vx6p6XD NJOcugO4kWM7UxE1wfszd77McANnUFTBdcvGA7MOZydR0LBcKZ3dphAsf358d9gI Kn04vDHqs33KrOadAWBpz1s6ul9Z0mxHIbkfxjBwNF5l1TVzNgAX6jb4ewBgZFqw GznIP8issuV1dyOYTo3qdKNt3Ihq1VxlGF6efBHZ6kfBBCc8Kgx9a6fe6GQWvfQ4 MGZ5bD63VsAfAhKhAd/zgAi4RhR2SLw88muIOu7hqL7A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=xJNreNlX7zIJlO8+D gDL6ZCtvYTVVTVGIzioKxhItXA=; b=ITnz5dx8d+9lRQ6dImwGOHVsb2Q3fbKZY 47Le33hTa/C0OjXN5MZcKcZPf+a4/s0aQHY3fVMRlfhidw7CuPyda3UjIOUn9l4v hMLI/KrFRV20YRtUTEyvzAJStbsZw6QVItgBr/my++LnvvlRPYSBfcApKErJqXkY O/irMl2Uv14Vi50juwhLaFml9bZKJYrOcoSOXi2Xqw0c759hw2pFUzMOfdhgANkp D+qIe16AyfqDYL1Me43jTRGKur6CqEoYZ5j2SCaA4b5G51gA6OsSjElJqAtxF+Kv Q7eeY+9wM1Mauz2SNFzlH9YV0++r5M3glxsdy8k3X6xOZzlXV7C7A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudeiledguddugecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffoggfgsedtkeertd ertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghkrghs hhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpedujeetlefhtd dtkefgtdeuieelhffgteejjeehkeegveduvdevgeeiheeuueekjeenucfkphepudegrdef rdeihedrudejheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Received: from workstation.flets-east.jp (ae065175.dynamic.ppp.asahi-net.or.jp [14.3.65.175]) by mail.messagingengine.com (Postfix) with ESMTPA id 673D1108005F; Sun, 4 Apr 2021 02:40:35 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [PATCH] ALSA: core: control_led: fix memory leak in snd_ctl_led_set_state() Date: Sun, 4 Apr 2021 15:40:31 +0900 Message-Id: <20210404064031.48711-1-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" When inquired control element is not in led group, snd_ctl_led_set_state() attempts to add the element into the group, according to function arguments. Although an memory object is allocated for led instance, it's left as is without being released. This commit fixes the memory leak. Fixes: 22d8de62f11b ("ALSA: control - add generic LED trigger module as the new control layer") Signed-off-by: Takashi Sakamoto --- sound/core/control_led.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/core/control_led.c b/sound/core/control_led.c index 788fd9e275e0..b97f118cd54e 100644 --- a/sound/core/control_led.c +++ b/sound/core/control_led.c @@ -161,6 +161,7 @@ static void snd_ctl_led_set_state(struct snd_card *card, unsigned int access, list_add(&lctl->list, &led->controls); UPDATE_ROUTE(route, snd_ctl_led_get(lctl)); } + kfree(lctl); } mutex_unlock(&snd_ctl_led_mutex); switch (led->mode) {