Message ID | 20221110144539.2989354-1-yebin@huaweicloud.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp177774wru; Thu, 10 Nov 2022 06:25:15 -0800 (PST) X-Google-Smtp-Source: AMsMyM5aiXYZAuDrCrLGYvZUq58jupnmxbC40Zv91ZcHYRv99Lea3UGoy/uCv65u0Li/IBSswIaR X-Received: by 2002:a17:90a:df8e:b0:213:8283:ac7f with SMTP id p14-20020a17090adf8e00b002138283ac7fmr1291580pjv.220.1668090315417; Thu, 10 Nov 2022 06:25:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668090315; cv=none; d=google.com; s=arc-20160816; b=laqZ1MmUThOQonCAWwSdUOE1AgiaPpXqdN11Ki8b5+0CdxLstRuW3kFrf+d4NGMwKQ irQPv6tsPZjsoj+FnZQaOQ1A7Vb/omEn9q/ZFmw4goj87TvFfKSWfgtRAbccb9y+2/9L ERX0a63T32fCIP/O0yxz0nxeySCvPmxJROLr6FB5Rcc8x1yl9mevLNNxXvc4mGiKQOnl 1wNkWiQZbcVgOzbz828ebl5mZBtx4zKOO/EeLKAHhanwSqaO764EUIPmuPX7zwmT4Zuf R9NSYe2M1RIq8PwyVW9Zak94I0KRpSnMLlWb9On8Hxt3XtGoaNOKemEE4mQSYJ9zufpp YehA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=0bexo8IXADJn94Tp5fNeyz4ltzA8IkhXKrVp8mj+n30=; b=NqaqnBntBrDf79d8MJZb+Qtk3JL5VVwt8VcANFivkOk4Rw8TYimUXWSLuEld7VNJ5A GelJ6ekauNoSncGFoACkYC7uehtuAqve6tSXnwanAY0RYMdk2Wh6veIesUDYXS+FwR9t BtJhbZJDYe4SXBHAtw0baG2YTJKOC08NPjAOm31wfCEuDgYudLedEs/4vyKACOO8blJV n+6w3BLswqAke+/6LxFK9UsB7DVLqdoGejqzKnClC2VbpbF6LsOsS6KQbNpLYHb3lhb2 iXZFBAHQGNw9f8i2nRHxlQtxnZ/kEvrc+atKlDgMnECNGLr/8k6TcvisXjRSzbVS5lPE E/mA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e23-20020a656897000000b004629cd1dbb1si20223142pgt.329.2022.11.10.06.24.59; Thu, 10 Nov 2022 06:25:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230055AbiKJOYT (ORCPT <rfc822;winker.wchi@gmail.com> + 99 others); Thu, 10 Nov 2022 09:24:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbiKJOYR (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 10 Nov 2022 09:24:17 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D17BD27DD3 for <linux-kernel@vger.kernel.org>; Thu, 10 Nov 2022 06:24:15 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4N7PGd0w3Mz4f3w0x for <linux-kernel@vger.kernel.org>; Thu, 10 Nov 2022 22:24:09 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP4 (Coremail) with SMTP id gCh0CgD3GtiKCW1jxQ4yAQ--.5594S4; Thu, 10 Nov 2022 22:24:12 +0800 (CST) From: Ye Bin <yebin@huaweicloud.com> To: perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org Cc: yebin10@huawei.com, linux-kernel@vger.kernel.org Subject: [PATCH] ALSA: hda: fix potential memleak in 'add_widget_node' Date: Thu, 10 Nov 2022 22:45:39 +0800 Message-Id: <20221110144539.2989354-1-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgD3GtiKCW1jxQ4yAQ--.5594S4 X-Coremail-Antispam: 1UD129KBjvdXoWrKFy5Kw18trW7Kr43XFy7KFg_yoWfArg_GF W8X3Z8uw1fGrnrK342yws5ZF4qgw43Aw18CrZayFnrAw47GrZ5trsrW3s0yr1UuFWSgFWU uryqq34DtFyIkjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbr8YFVCjjxCrM7AC8VAFwI0_Gr0_Xr1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_JFC_Wr1l1IIY67AEw4v_Jr0_Jr4l8cAvFVAK0II2c7xJM28CjxkF64kEwV A0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x02 67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I 0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40E x7xfMcIj6xIIjxv20xvE14v26r106r15McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x 0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Y z7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zV AF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4l IxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWrJr0_WF yUJwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIY CTnIWIevJa73UjIFyTuYvjxUOyCJDUUUU X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749119470820950397?= X-GMAIL-MSGID: =?utf-8?q?1749119470820950397?= |
Series |
ALSA: hda: fix potential memleak in 'add_widget_node'
|
|
Commit Message
Ye Bin
Nov. 10, 2022, 2:45 p.m. UTC
From: Ye Bin <yebin10@huawei.com> As 'kobject_add' may allocated memory for 'kobject->name' when return error. And in this function, if call 'kobject_add' failed didn't free kobject. So call 'kobject_put' to recycling resources. Signed-off-by: Ye Bin <yebin10@huawei.com> --- sound/hda/hdac_sysfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Comments
On Thu, 10 Nov 2022 15:45:39 +0100, Ye Bin wrote: > > From: Ye Bin <yebin10@huawei.com> > > As 'kobject_add' may allocated memory for 'kobject->name' when return error. > And in this function, if call 'kobject_add' failed didn't free kobject. > So call 'kobject_put' to recycling resources. > > Signed-off-by: Ye Bin <yebin10@huawei.com> Thanks, applied now. Takashi
diff --git a/sound/hda/hdac_sysfs.c b/sound/hda/hdac_sysfs.c index e47de49a32e3..62a9615dcf52 100644 --- a/sound/hda/hdac_sysfs.c +++ b/sound/hda/hdac_sysfs.c @@ -346,8 +346,10 @@ static int add_widget_node(struct kobject *parent, hda_nid_t nid, return -ENOMEM; kobject_init(kobj, &widget_ktype); err = kobject_add(kobj, parent, "%02x", nid); - if (err < 0) + if (err < 0) { + kobject_put(kobj); return err; + } err = sysfs_create_group(kobj, group); if (err < 0) { kobject_put(kobj);