Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1445113rdb; Mon, 2 Oct 2023 09:39:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHQfHCxVmAyD9Fuk3vMVl3jacrQ+7ACGGtoGmMtiNX5DEfHRUq0lLwGbiCYyQLOxUS6rIHA X-Received: by 2002:a17:902:ee45:b0:1c1:d4f4:cd3c with SMTP id 5-20020a170902ee4500b001c1d4f4cd3cmr10411442plo.31.1696264778217; Mon, 02 Oct 2023 09:39:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696264778; cv=none; d=google.com; s=arc-20160816; b=MP2C6VYpZHOQDcalrKt/37Slc6D/mcfSDYPdJt4aD9SvqNB6jkL4NS/+YMwM9Fme1e eXARyMHwkk4m5+rrBm7REpe4IBxqzJ6AylG+NP9gJoI1OfzSQpzvjz0AlSjFTvINuFkO c5Lf47vgE8yBNtaE67RWto7aaeWTWtjI63Jnl2Tu3lsQ/ud9F7L5CHXS6BCK3VOhUOCa 7gk6XvGDWEHr8L4q8GqpkuPQTnZhaGCDzLxPa+YAs3YrvXud59c5uSPAnzyoC8O/mFa4 jMMkq0+X2xfbHBfV7xUZTY31vVGweBSKBRKzrAbQc7I0LTIsZYWW5n7Mzn3lqXqE+yrU NE/A== 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=UuiJAasJFuJugsUCq7uAwuSqbHbQ2+esM38ojBj3VmM=; fh=SGfIz9Fd/iZ99861jOmY+XD9kPqsBz1Gf7L1Y4CZNDQ=; b=jOOfjaP+H1xKlZMYy7kTtOyL57CnGIoWGIU415YfL2O2bYhEAQx+YbLaDhestF44ui OQXfiiJLLeXDWScf7fnBpzOgZIwbrzZJYEVELl+IKNB1f6QFIfu2GaqaTzsWDt2Mr9Qf 8Ls9lIf6OWPO58dgWBrR6NtTat1tLxASyUZJAXcjL5KKwwMhKAHpDdCkTvnBxKBRT7YH aezs039p1PxCnX4n9TfZWmxalyvk1bZvjsLQ2RWbRFN+b3C7RYQIzUJWUnBzOozgXH0H J2693CAkosRp/QvYmdLgGylD12NJkxgc9RP3THsDOb5EvRuSngtNR1asRB+/r9hD7CC/ S5zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OpqjdQ+R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id d6-20020a170903230600b001c7345bc01csi11980421plh.450.2023.10.02.09.39.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 09:39:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OpqjdQ+R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id E7C548047D5E; Mon, 2 Oct 2023 02:37:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236121AbjJBJh1 (ORCPT + 99 others); Mon, 2 Oct 2023 05:37:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230506AbjJBJhZ (ORCPT ); Mon, 2 Oct 2023 05:37:25 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8991F83; Mon, 2 Oct 2023 02:37:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696239442; x=1727775442; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=uRt1ae+PaFLvuL/WtDM9bT7telz1ws3WCIW7qDvGk1I=; b=OpqjdQ+RfN2HHXUytaVXv+98kieVoqp66+s0a1hUD1s4lmWNUzzbLgZo U+ajP9d2+Cw8demaNymvpvl8erEDdeuKQhB4PV9gcqx7QqnZdh6cxiWfg 7PX3285lyv9PIjWThNgYmeKtf5xOabs9y7YYPMH8JPM0Jnrg68GUKflkF syVqlZmADsHe5uYtXV23WC8E/vgfnFfFnS7k4PSaQMSNALPLsRJJggCZv jgn9juTo09AcD5k+v4ie5b13q8C7iMuuj6ltn0uY+GyyisJD4AcXMp5LF dawsqdGxC71LCL2D1wrP++KDnaJJ2WmqTNzbtVEkImY1m2S6V216irOVG Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10850"; a="361987748" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="361987748" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2023 02:37:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10850"; a="997573837" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="997573837" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga006.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2023 02:37:07 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.97-RC0) (envelope-from ) id 1qnFMO-000000027Z7-0xKM; Mon, 02 Oct 2023 12:37:04 +0300 Date: Mon, 2 Oct 2023 12:37:03 +0300 From: Andy Shevchenko To: Michal Wilczynski Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, rafael.j.wysocki@intel.com, lenb@kernel.org, dan.j.williams@intel.com, vishal.l.verma@intel.com, ira.weiny@intel.com Subject: Re: [PATCH v1 1/2] ACPI: NFIT: Fix memory leak, and local use of devm_*() Message-ID: References: <20230926184520.2239723-1-michal.wilczynski@intel.com> <20230926184520.2239723-2-michal.wilczynski@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230926184520.2239723-2-michal.wilczynski@intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 02 Oct 2023 02:37:31 -0700 (PDT) On Tue, Sep 26, 2023 at 09:45:19PM +0300, Michal Wilczynski wrote: > devm_*() family of functions purpose is managing memory attached to a > device. So in general it should only be used for allocations that should > last for the whole lifecycle of the device. This is not the case for > acpi_nfit_init_interleave_set(). There are two allocations that are only > used locally in this function. What's more - if the function exits on > error path memory is never freed. It's still attached to dev and would > be freed on device detach, so this leak could be called a 'local leak'. > > Fix this by switching from devm_kcalloc() to kcalloc(), and adding > proper rollback. LGTM, Reviewed-by: Andy Shevchenko -- With Best Regards, Andy Shevchenko