Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp263354pxb; Fri, 15 Jan 2021 12:24:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJzLwhR2m+GkPS19Aj7BfvNVqY9TSMayOgQo3oScRz1dbkn5pHsWv+X4UJx0z8xV3Q22+4BC X-Received: by 2002:a05:6402:b88:: with SMTP id cf8mr11507593edb.140.1610742286108; Fri, 15 Jan 2021 12:24:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610742286; cv=none; d=google.com; s=arc-20160816; b=nJIwjhelnNjOKA7XE0GHhgRplzcNYE6kJsv6yTRsaJj+js3bjUVDorG4dPuTReK2Um OVCkkFciErIqJN0qUh6LFj7EgdTZudKciTiug6gt29Kndopbiv3jvctCdHepJlqcoDEB CeaV3Ni+zS4aDGlX3eFpZqsPPbvZ3YDszBcaY0syS/qFKZDCTQNGGwMMWOKMDb9xi/Fx TQNA+CnPcj75LxdbXYuwoEv8R6slsBR639FFbHef+stMxQ7lxw5uf5W7BYLIQ9EJrRMx 9DK31HP9m8QK37LyMUlBkuEqiwVptA6Ux5zs5/jwLmVNsXbfd1OG2+KLERZPPLNNX4vJ puJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=uMf/40ZOBursAcunQbNmwliT9GLzVostWCpfGDtK61s=; b=KcnKVo+fk6OFKCzy1l+V6iiNbAmVGdPay+tyYGdOmhdkkMBwppqMlH0CPlM5un2Tce nKPvrjXov59XO6sYz1kFjHuRGFO58kRUIuH1N58kiwybf3cCqiJWURtY7gox307RVEIU ClRuVOMwsbZWL0wZ2odH55DCxQsXFe3+VB3VFPvaX2yxWd4J70BEuT2b734qsN1HsK18 SiA5h43EZ1/CUYp26dH+GRV/siM19rRvT3L7FPtNrRrl10LuIJ/5lPtnUbiTPCRadOte cWPGnlbydO1WlTSDI4K+COQQoNvTSqoD+2qN2sSG9QTtqM+qQmr5G8l++eEgCpG+yNKl BEBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=r4HR8iIC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z27si4603158edl.135.2021.01.15.12.24.21; Fri, 15 Jan 2021 12:24:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=r4HR8iIC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733265AbhAOUXO (ORCPT + 99 others); Fri, 15 Jan 2021 15:23:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731529AbhAOUXF (ORCPT ); Fri, 15 Jan 2021 15:23:05 -0500 Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAC7BC061757; Fri, 15 Jan 2021 12:22:24 -0800 (PST) Received: by mail-qt1-x82e.google.com with SMTP id v5so6968580qtv.7; Fri, 15 Jan 2021 12:22:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=uMf/40ZOBursAcunQbNmwliT9GLzVostWCpfGDtK61s=; b=r4HR8iICuMdp2jfdiVmjAzp+pkoLhnv4i1xsKfoO51eTUIkYMhUWDw/gNZvJsf4aB5 7WyWXScXOaX8gPCAYN4gvzwgC2ojlgiHflOW6Grlik3KPtnJt9FjFcOhLb3Iv89h+WMK Cgoc+OWYzjBnAt6odVF+IJw8vgNjJG7qv1TieWSsySuke2x/lw0XKLyyKAE7W7xJMUOo CZ7BT8hzl5K6PdVNLT3+QvdeNJI1dqx1YV1NzQOEKzOBUl+nP7gIXGVq8wpKU+G5oKS0 O0nagHnNw883bdfHDtMPqFysbfkq9ftGZ9tllPnRnLsFixKJ5EduwujhU8/SPkvmWEK+ xwwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=uMf/40ZOBursAcunQbNmwliT9GLzVostWCpfGDtK61s=; b=l6AWWk7CFDR9e+Jf9WA3Yt2Ieu6raNtDUWAWkYGi0i8O+Jud9mq7Qn95ZzpamW4Az3 A8yYuPnNG7H1dkeU3y1erjcKTjq9X35aSKZTJogiDMrezBWdcCtJRhpc0zc8aKztNyC8 vITO2UramwqB9xzyAmAv+WuU+rnu8/czA9IQIxv2+Doq2useaIQCA7xBRXdjRo0atyod FNla4HcIvPFWjQZ17u/XpixIJwQVOxgr+rrp0mH8V5jZS8fqv2d57Toq6hdfZ5vOx+an x1MJySakOkDEq0guNH07hTLyP7G6BiN9J9isymEvYhVIaqy72iIJ6Umh7+wVSFdy9Ipt +zXw== X-Gm-Message-State: AOAM530JpaY3oMDYoCMvKIAvYwO5tE0cCU28voGDk8T5Ksro4dlVcQfp nVdOI8W7ePIwgrK2Sd7MzhY7ul56yR8= X-Received: by 2002:aed:23d6:: with SMTP id k22mr13752718qtc.226.1610742143863; Fri, 15 Jan 2021 12:22:23 -0800 (PST) Received: from ubuntu-m3-large-x86 ([2604:1380:45f1:1d00::1]) by smtp.gmail.com with ESMTPSA id 38sm3268337qtb.67.2021.01.15.12.22.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 12:22:23 -0800 (PST) Date: Fri, 15 Jan 2021 13:22:21 -0700 From: Nathan Chancellor To: Pavel Machek Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Xiaolei Wang , Mark Brown Subject: Re: [PATCH 5.10 086/103] regmap: debugfs: Fix a memory leak when calling regmap_attach_dev Message-ID: <20210115202221.GA209258@ubuntu-m3-large-x86> References: <20210115122006.047132306@linuxfoundation.org> <20210115122010.175920983@linuxfoundation.org> <20210115201819.GA8375@amd> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210115201819.GA8375@amd> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 15, 2021 at 09:18:19PM +0100, Pavel Machek wrote: > Hi! > > > From: Xiaolei Wang > > > > commit cffa4b2122f5f3e53cf3d529bbc74651f95856d5 upstream. > > > > After initializing the regmap through > > syscon_regmap_lookup_by_compatible, then regmap_attach_dev to the > > device, because the debugfs_name has been allocated, there is no > > need to redistribute it again > > ? redistribute? > > Anyway, this patch is clearly buggy: > > > > > if (!strcmp(name, "dummy")) { > > - kfree(map->debugfs_name); > > + if (!map->debugfs_name) > > + kfree(map->debugfs_name); > > > > It runs kfree only if the variable is NULL. That's clearly useless, > kfree(NULL) is NOP, and this causes memory leak. Fixed by commit f6bcb4c7f366 ("regmap: debugfs: Fix a reversed if statement in regmap_debugfs_init()") in mainline. Cheers, Nathan