Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp2903841rwo; Mon, 24 Jul 2023 03:15:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlGMfZKHsPWeExPLNHZR5rjW/SgFBCgm+HsqdVKm1NLHTFYU+Kq05DoiIlBsSb7ruMrEkTEi X-Received: by 2002:a05:6a00:99a:b0:681:9004:3a20 with SMTP id u26-20020a056a00099a00b0068190043a20mr12052643pfg.7.1690193709157; Mon, 24 Jul 2023 03:15:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690193709; cv=none; d=google.com; s=arc-20160816; b=wiKmak3+9LQ0Pda7+ILfNIQTRsFDCNDpob/f75cbrSiJnRDd9kSJnJ3ozAkwNP2+si 6UBOetvC4v4QDBXH1Qnh1EKkR6DX//nMTqe+nHSgFVIapxu1MGz435yFNpYe0iWeK3Qr TYfl6gnw76gXHuJZQY/OsHzRM7AWP4VFP+KJZLECPFsRbUPu3/mFh2Ch7rNKNT3OND+x BuFpOenff7gpoRQ6zs1AeTFqqG1KYzNEtYx6RQOjQ9mffalp74dPCtQIpkbLeKq+u7f7 /LTAKuvWMMV3qwjes3nKjTXNV6b2R7LVW2nDcn1YLkNq6vwGPrEp97+FxZo7M95idc/i Pegg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=BOtWhnE0ptY8wcebyr//0s2EGgw3T00JLeCvrktwDZ4=; fh=aTedIgObO+7KDXbvbouT3TCg23rQoTR3zAQRB3nmguc=; b=veYyzayWRtqZmwJH7yI4SLsGKjP2AkCpd5cVtEAkEl8VvQtfsUC02rw2GUgeqfdGQ2 vAIAOnajXhYTSoO4FKrMDaJbFYO3x0+2JAcEoGU3wKOfSkviPVwJ0dc5r0Sb/1os0xuE aeBKJA0+gQzKS3rtgIGeEabFszlCaWfVGKZknzQNYufIwp0esuOF6Z31zYZRjikQEHVr XA/YZsXsPoa7l3MvAZBhw13pPyJYJsPVxnKakn9E1SAghe2jpHwMu/c0S4JbBzndhiwH 4tTK+Q4cWrAyJFF7ISsnqOkfKv9c+nbpv8Zi2mPSsaAGadBPBUSCA/p71yCf5nIlbXuE 3rnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NOFNbbZU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s15-20020a63af4f000000b0055fe860330bsi8945314pgo.205.2023.07.24.03.14.57; Mon, 24 Jul 2023 03:15:09 -0700 (PDT) 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; dkim=pass header.i=@intel.com header.s=Intel header.b=NOFNbbZU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232684AbjGXKAh (ORCPT + 99 others); Mon, 24 Jul 2023 06:00:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232965AbjGXKAN (ORCPT ); Mon, 24 Jul 2023 06:00:13 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2D784ED5 for ; Mon, 24 Jul 2023 02:54:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690192457; x=1721728457; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=scpBJ577mRimOo62TKgu6+oiwI4ovv5AJtXfkH9zf/A=; b=NOFNbbZUe5n4JU18bP4d/K7dRUqW0jATwVRi2pgcwlTJFQ/Bs0TgFDbY IRj9aNn2+D+eXDGt1G0Qq1MUYBtK9yE8Py8aCrg7Ytp1Etk89F4FbDwJD vF6Mq7wpN/F0mocOjdWIjxB/6KolrrkZJyxhxhKY2mhdSMbDQ0h5X6Egd 6AEUTUIVPic6DRzr9rabcrbYuhkDCU0r8dHGQok/DlwtfSnuVBHtQkGlz QHrO0/Ekc7Xukvqm+RwB+uKbPx8dHH06OrUHUeusqtrSN0b9YESznoeXH ZR4rRTUWxh0dQHCLC4M8Y7JpnOVcPM3vQDRiQy2Mk0GW9d2IvunGiOifY g==; X-IronPort-AV: E=McAfee;i="6600,9927,10780"; a="367423782" X-IronPort-AV: E=Sophos;i="6.01,228,1684825200"; d="scan'208";a="367423782" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2023 02:52:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10780"; a="972201808" X-IronPort-AV: E=Sophos;i="6.01,228,1684825200"; d="scan'208";a="972201808" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga006.fm.intel.com with ESMTP; 24 Jul 2023 02:52:16 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1qNsEg-007Lw4-1L; Mon, 24 Jul 2023 12:52:14 +0300 Date: Mon, 24 Jul 2023 12:52:14 +0300 From: Andy Shevchenko To: Pierre-Louis Bossart Cc: Brent Lu , alsa-devel@alsa-project.org, Cezary Rojewski , Liam Girdwood , Peter Ujfalusi , Bard Liao , Ranjani Sridharan , Kai Vehmanen , Mark Brown , Jaroslav Kysela , Takashi Iwai , linux-kernel@vger.kernel.org, Yong Zhi , Ajye Huang , Uday M Bhat , Terry Cheong , Mac Chiang , "Dharageswari . R" , Kuninori Morimoto Subject: Re: [PATCH 1/2] ASoC: Intel: maxim-common: get codec number from ACPI Message-ID: References: <20230720092628.758834-1-brent.lu@intel.com> <20230720092628.758834-2-brent.lu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 24, 2023 at 11:08:17AM +0200, Pierre-Louis Bossart wrote: > On 7/20/23 11:26, Brent Lu wrote: ... > > +/* helper function to get the number of specific codec */ ...and leak a lot of reference counts... > > +static int get_num_codecs(const char *hid) > > +{ > > + struct acpi_device *adev = NULL; > > + int dev_num = 0; > > + > > + do { > > + adev = acpi_dev_get_next_match_dev(adev, hid, NULL, -1); > > Humm, I am a bit worried about reference counts. > > See > https://elixir.bootlin.com/linux/latest/source/drivers/acpi/utils.c#L916, > it's not clear to me where the get() is done. > > Adding Andy to make sure this is done right. Thank you for Cc'ing. Yes, the above code is problematic. One has to use the respective for_each macro (defined nearby the used API). > > + if (adev) > > + dev_num++; > > + } while (adev != NULL); > > + > > + return dev_num; > > +} -- With Best Regards, Andy Shevchenko