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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 727F4C6FD18 for ; Tue, 28 Mar 2023 15:54:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233954AbjC1PyD (ORCPT ); Tue, 28 Mar 2023 11:54:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233502AbjC1Pxv (ORCPT ); Tue, 28 Mar 2023 11:53:51 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73A21E07E; Tue, 28 Mar 2023 08:53:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680018814; x=1711554814; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=8XFKOae6uPzdUjobd8irY9Q2YB4mHOqUzbdqMlqGg0s=; b=n/T43Ee+M2yXtFiojcPewn/vFWU51GN3od1OiaYZN1qds2reoJeadT5h MKZQyG1e6BPHH7YrtxnLQgNoIkC1WDsNMK6jlbFQxkqCA7xD1YWvesTiv 4Is2gPucq80Kklmi5VAfQuLE7NPpz5r/A2OMRqh1paUAXWOT+28Z6RFMY 1cQ5ZWbmS/XuHPLNh5bRnZYj7m4Y35B9No0NX3wOfcUKsv45c4/+cQLc5 JEagy6nnxH/8lAQEEMyW/FzVS3C6BKsl9NA167g3PzB1QDA5a3cSZWMIZ VP7jtfdwhH0iPwCm/6cqcPFfyOQW4nc6D9RJTHboO/K33GpdJtgT8OTve A==; X-IronPort-AV: E=McAfee;i="6600,9927,10663"; a="339329964" X-IronPort-AV: E=Sophos;i="5.98,297,1673942400"; d="scan'208";a="339329964" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2023 08:53:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10663"; a="858145982" X-IronPort-AV: E=Sophos;i="5.98,297,1673942400"; d="scan'208";a="858145982" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga005.jf.intel.com with ESMTP; 28 Mar 2023 08:53:16 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1phBdL-009gOw-1R; Tue, 28 Mar 2023 18:53:15 +0300 Date: Tue, 28 Mar 2023 18:53:15 +0300 From: Andy Shevchenko To: Sakari Ailus Cc: linux-acpi@vger.kernel.org, linux-media@vger.kernel.org, rafael@kernel.org, heikki.krogerus@linux.intel.com Subject: Re: [PATCH v7 03/10] ACPI: property: Parse _CRS CSI-2 descriptor Message-ID: References: <20230328101303.1458570-1-sakari.ailus@linux.intel.com> <20230328101303.1458570-4-sakari.ailus@linux.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 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org On Tue, Mar 28, 2023 at 06:48:18PM +0300, Sakari Ailus wrote: > On Tue, Mar 28, 2023 at 06:46:23PM +0300, Andy Shevchenko wrote: > > On Tue, Mar 28, 2023 at 06:27:09PM +0300, Sakari Ailus wrote: > > > On Tue, Mar 28, 2023 at 06:12:09PM +0300, Andy Shevchenko wrote: > > > > On Tue, Mar 28, 2023 at 01:12:56PM +0300, Sakari Ailus wrote: ... > > > > > + struct scan_check_crs_csi2_context inst_context = { > > > > > + .handle = handle, > > > > > + .res_head = LIST_HEAD_INIT(inst_context.res_head), > > > > > + }; > > > > > + struct crs_csi2 *csi2; > > > > > + > > > > > + acpi_walk_resources(handle, METHOD_NAME__CRS, > > > > > + scan_check_crs_csi2_instance, &inst_context); > > > > > + > > > > > + if (list_empty(&inst_context.res_head)) > > > > > + return; > > > > > + > > > > > + /* > > > > > + * Found entry, so allocate memory for it, fill it and add it to the > > > > > + * list. > > > > > + */ > > > > > + csi2 = kmalloc(sizeof(*csi2), GFP_KERNEL); > > > > > + if (!csi2) > > > > > > > > Who is going to release resources allocated in the callback above? > > > > > > This is done by crs_csi2_release(), called from acpi_bus_scan_crs_csi2(). > > > > Isn't it a bit counter intuitive? > > Are you suggesting changing something? > > Basically we're gathering the information during an ACPI namespace walk. > Once the information has been processed and used, the memory can be > released. Release allocated memory in the function which allocates it. Since it's called via callback, the closest one is the one that calls acpi_walk_resources(). Can't we free them here? -- With Best Regards, Andy Shevchenko