Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp19238pxb; Fri, 15 Jan 2021 04:51:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJz9Dkt1OJkiu0RK5a/pV5Xdx56kXWun+FEy7sYyLZOkgqKa9ODrknGeXmhSqsvA9PJvZqH1 X-Received: by 2002:a17:906:c7d9:: with SMTP id dc25mr8905604ejb.138.1610715075837; Fri, 15 Jan 2021 04:51:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610715075; cv=none; d=google.com; s=arc-20160816; b=jAuIbseJtn09pVPX3e4AxO/snkSbIfz7aXMzwI3Bt3KyZqvvQJi9GIXKD7DYIOcgQk FRryQIp5eV16WYmwcsYceRA0rrHYdgrnfPAPWNCunwnYb7m3B/cw0zFoSqxQrZXYa0tf +vyewfcg2PTB75ooP8lYeaenQR8yrlp61jziA5MLfiSaQ3BcAv879lAH14bje7bfVIEW FguCdc4iEo3Wp7v4kc7TDr3mqQMbO5ZpHpxvWbQ2fSKdjiwOGuXeRQiAi6Twm+PR885F N697BAMapaBROYkxuvTNA/jKFKPE8eHkcLo8eSP4xQpLxTgdExsQFdywJZ3K9W+v+JLl 99Ew== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3+kD/mz8sEyeA/rNE9aZSWUB4OTZbwJnTUudzgF9Md0=; b=BKK5AWVwpQ4ArDOgpR9ORF1QzBBEvNb0spefLEU3P2VyAt0XLWSIWF8F5FXIgrl6xj yNebiBS/klamYOeAPOGTjkULHrovegW2HpJ/E1UoDX74J5PPSWsQZNW2lrjL1Y7x0SIB XcWBGFA0XpGc426yB32ViOMCWUqMI1BR1lqaCisjjJ1MRBmED9nNMrzAVMX+xABiqxCR XPQUgVXb1L6qmBkNEqJ8zQZSgemxDGszHQPwo6BDgvIu101N4q/OR6Jtn2IDmdoNYEKE L2R2WiylUJ1zp3fyzrfz1AS93lh624UtFBBnouim33Vt07xuKiDW6HTefoq7/s0nYjSY wQfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tPcRmldu; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h19si3631900ejy.455.2021.01.15.04.50.52; Fri, 15 Jan 2021 04:51:15 -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=@linuxfoundation.org header.s=korg header.b=tPcRmldu; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387866AbhAOMuY (ORCPT + 99 others); Fri, 15 Jan 2021 07:50:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:43340 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387858AbhAOMgO (ORCPT ); Fri, 15 Jan 2021 07:36:14 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 958CE2339D; Fri, 15 Jan 2021 12:35:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610714134; bh=oFSGIXMlyZru2J8N4EfZLjSXyH9mwZLVMkgDcu4YNmY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tPcRmlduWcwBwPgjQEsY8oa9COw8d0vYxVelGycPplv6CReai7OXNZPZfUHrTwKe2 UdlbB8YReEVTYixabnhTAdncYIz7TjQLIA6bK88I75eJJE/BzGhqEyM1y7cdgIWgbt Ocbh+3vpgkGPsEZWqd/C46JcJE5tjxU1DEdbI9Jc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Mark Brown Subject: [PATCH 5.4 62/62] regmap: debugfs: Fix a reversed if statement in regmap_debugfs_init() Date: Fri, 15 Jan 2021 13:28:24 +0100 Message-Id: <20210115122001.378145241@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210115121958.391610178@linuxfoundation.org> References: <20210115121958.391610178@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter commit f6bcb4c7f366905b66ce8ffca7190118244bb642 upstream. This code will leak "map->debugfs_name" because the if statement is reversed so it only frees NULL pointers instead of non-NULL. In fact the if statement is not required and should just be removed because kfree() accepts NULL pointers. Fixes: cffa4b2122f5 ("regmap: debugfs: Fix a memory leak when calling regmap_attach_dev") Signed-off-by: Dan Carpenter Link: https://lore.kernel.org/r/X/RQpfAwRdLg0GqQ@mwanda Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- drivers/base/regmap/regmap-debugfs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) --- a/drivers/base/regmap/regmap-debugfs.c +++ b/drivers/base/regmap/regmap-debugfs.c @@ -595,9 +595,7 @@ void regmap_debugfs_init(struct regmap * } if (!strcmp(name, "dummy")) { - if (!map->debugfs_name) - kfree(map->debugfs_name); - + kfree(map->debugfs_name); map->debugfs_name = kasprintf(GFP_KERNEL, "dummy%d", dummy_index); if (!map->debugfs_name)