linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Xiaolei Wang <xiaolei.wang@windriver.com>,
	Mark Brown <broonie@kernel.org>
Subject: [PATCH 5.10 086/103] regmap: debugfs: Fix a memory leak when calling regmap_attach_dev
Date: Fri, 15 Jan 2021 13:28:19 +0100	[thread overview]
Message-ID: <20210115122010.175920983@linuxfoundation.org> (raw)
In-Reply-To: <20210115122006.047132306@linuxfoundation.org>

From: Xiaolei Wang <xiaolei.wang@windriver.com>

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

unreferenced object 0xd8399b80 (size 64):
  comm "swapper/0", pid 1, jiffies 4294937641 (age 278.590s)
  hex dump (first 32 bytes):
	64 75 6d 6d 79 2d 69 6f 6d 75 78 63 2d 67 70 72
dummy-iomuxc-gpr
	40 32 30 65 34 30 30 30 00 7f 52 5b d8 7e 42 69
@20e4000..R[.~Bi
  backtrace:
    [<ca384d6f>] kasprintf+0x2c/0x54
    [<6ad3bbc2>] regmap_debugfs_init+0xdc/0x2fc
    [<bc4181da>] __regmap_init+0xc38/0xd88
    [<1f7e0609>] of_syscon_register+0x168/0x294
    [<735e8766>] device_node_get_regmap+0x6c/0x98
    [<d96c8982>] imx6ul_init_machine+0x20/0x88
    [<0456565b>] customize_machine+0x1c/0x30
    [<d07393d8>] do_one_initcall+0x80/0x3ac
    [<7e584867>] kernel_init_freeable+0x170/0x1f0
    [<80074741>] kernel_init+0x8/0x120
    [<285d6f28>] ret_from_fork+0x14/0x20
    [<00000000>] 0x0

Fixes: 9b947a13e7f6 ("regmap: use debugfs even when no device")
Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
Link: https://lore.kernel.org/r/20201229105046.41984-1-xiaolei.wang@windriver.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/base/regmap/regmap-debugfs.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -582,18 +582,25 @@ void regmap_debugfs_init(struct regmap *
 		devname = dev_name(map->dev);
 
 	if (name) {
-		map->debugfs_name = kasprintf(GFP_KERNEL, "%s-%s",
+		if (!map->debugfs_name) {
+			map->debugfs_name = kasprintf(GFP_KERNEL, "%s-%s",
 					      devname, name);
+			if (!map->debugfs_name)
+				return;
+		}
 		name = map->debugfs_name;
 	} else {
 		name = devname;
 	}
 
 	if (!strcmp(name, "dummy")) {
-		kfree(map->debugfs_name);
+		if (!map->debugfs_name)
+			kfree(map->debugfs_name);
 
 		map->debugfs_name = kasprintf(GFP_KERNEL, "dummy%d",
 						dummy_index);
+		if (!map->debugfs_name)
+				return;
 		name = map->debugfs_name;
 		dummy_index++;
 	}



  parent reply	other threads:[~2021-01-15 12:39 UTC|newest]

Thread overview: 116+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-15 12:26 [PATCH 5.10 000/103] 5.10.8-rc1 review Greg Kroah-Hartman
2021-01-15 12:26 ` [PATCH 5.10 001/103] powerpc/32s: Fix RTAS machine check with VMAP stack Greg Kroah-Hartman
2021-01-15 12:26 ` [PATCH 5.10 002/103] io_uring: synchronise IOPOLL on task_submit fail Greg Kroah-Hartman
2021-01-15 12:26 ` [PATCH 5.10 003/103] io_uring: limit {io|sq}poll submit locking scope Greg Kroah-Hartman
2021-01-15 12:26 ` [PATCH 5.10 004/103] io_uring: patch up IOPOLL overflow_flush sync Greg Kroah-Hartman
2021-01-15 12:26 ` [PATCH 5.10 005/103] RDMA/hns: Avoid filling sl in high 3 bits of vlan_id Greg Kroah-Hartman
2021-01-15 12:26 ` [PATCH 5.10 006/103] iommu/arm-smmu-qcom: Initialize SCTLR of the bypass context Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 007/103] drm/panfrost: Dont corrupt the queue mutex on open/close Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 008/103] io_uring: Fix return value from alloc_fixed_file_ref_node Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 009/103] scsi: ufs: Fix -Wsometimes-uninitialized warning Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 010/103] btrfs: skip unnecessary searches for xattrs when logging an inode Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 011/103] btrfs: fix deadlock when cloning inline extent and low on free metadata space Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 012/103] btrfs: shrink delalloc pages instead of full inodes Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 013/103] net: cdc_ncm: correct overhead in delayed_ndp_size Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 014/103] net: hns3: fix incorrect handling of sctp6 rss tuple Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 015/103] net: hns3: fix the number of queues actually used by ARQ Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 016/103] net: hns3: fix a phy loopback fail issue Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 017/103] net: stmmac: dwmac-sun8i: Fix probe error handling Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 018/103] net: stmmac: dwmac-sun8i: Balance internal PHY resource references Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 019/103] net: stmmac: dwmac-sun8i: Balance internal PHY power Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 020/103] net: stmmac: dwmac-sun8i: Balance syscon (de)initialization Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 021/103] net: vlan: avoid leaks on register_vlan_dev() failures Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 022/103] net/sonic: Fix some resource leaks in error handling paths Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 023/103] net: bareudp: add missing error handling for bareudp_link_config() Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 024/103] ptp: ptp_ines: prevent build when HAS_IOMEM is not set Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 025/103] net: ipv6: fib: flush exceptions when purging route Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 026/103] tools: selftests: add test for changing routes with PTMU exceptions Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 027/103] net: fix pmtu check in nopmtudisc mode Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 028/103] net: ip: always refragment ip defragmented packets Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 029/103] chtls: Fix hardware tid leak Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 030/103] chtls: Remove invalid set_tcb call Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 031/103] chtls: Fix panic when route to peer not configured Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 032/103] chtls: Avoid unnecessary freeing of oreq pointer Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 033/103] chtls: Replace skb_dequeue with skb_peek Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 034/103] chtls: Added a check to avoid NULL pointer dereference Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 035/103] chtls: Fix chtls resources release sequence Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 036/103] octeontx2-af: fix memory leak of lmac and lmac->name Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 037/103] nexthop: Fix off-by-one error in error path Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 038/103] nexthop: Unlink nexthop group entry " Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 039/103] nexthop: Bounce NHA_GATEWAY in FDB nexthop groups Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 040/103] s390/qeth: fix deadlock during recovery Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 041/103] s390/qeth: fix locking for discipline setup / removal Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 042/103] s390/qeth: fix L2 header access in qeth_l3_osa_features_check() Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 043/103] net: dsa: lantiq_gswip: Exclude RMII from modes that report 1 GbE Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 044/103] net/mlx5: Use port_num 1 instead of 0 when delete a RoCE address Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 045/103] net/mlx5e: ethtool, Fix restriction of autoneg with 56G Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 046/103] net/mlx5e: In skb build skip setting mark in switchdev mode Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 047/103] net/mlx5: Check if lag is supported before creating one Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 048/103] scsi: lpfc: Fix variable vport set but not used in lpfc_sli4_abts_err_handler() Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 049/103] ionic: start queues before announcing link up Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 050/103] HID: wacom: Fix memory leakage caused by kfifo_alloc Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 051/103] fanotify: Fix sys_fanotify_mark() on native x86-32 Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 052/103] ARM: OMAP2+: omap_device: fix idling of devices during probe Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 053/103] i2c: sprd: use a specific timeout to avoid system hang up issue Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 054/103] dmaengine: dw-edma: Fix use after free in dw_edma_alloc_chunk() Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 055/103] selftests/bpf: Clarify build error if no vmlinux Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 056/103] can: tcan4x5x: fix bittiming const, use common bittiming from m_can driver Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 057/103] can: m_can: m_can_class_unregister(): remove erroneous m_can_clk_stop() Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 058/103] can: kvaser_pciefd: select CONFIG_CRC32 Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 059/103] spi: spi-geni-qcom: Fail new xfers if xfer/cancel/abort pending Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 060/103] cpufreq: powernow-k8: pass policy rather than use cpufreq_cpu_get() Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 061/103] spi: spi-geni-qcom: Fix geni_spi_isr() NULL dereference in timeout case Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 062/103] spi: stm32: FIFO threshold level - fix align packet size Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 063/103] i2c: i801: Fix the i2c-mux gpiod_lookup_table not being properly terminated Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 064/103] i2c: mediatek: Fix apdma and i2c hand-shake timeout Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 065/103] bcache: set bcache device into read-only mode for BCH_FEATURE_INCOMPAT_OBSO_LARGE_BUCKET Greg Kroah-Hartman
2021-01-15 12:27 ` [PATCH 5.10 066/103] interconnect: imx: Add a missing of_node_put after of_device_is_available Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 067/103] interconnect: qcom: fix rpmh link failures Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 068/103] dmaengine: mediatek: mtk-hsdma: Fix a resource leak in the error handling path of the probe function Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 069/103] dmaengine: milbeaut-xdmac: " Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 070/103] dmaengine: xilinx_dma: check dma_async_device_register return value Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 071/103] dmaengine: xilinx_dma: fix incompatible param warning in _child_probe() Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 072/103] dmaengine: xilinx_dma: fix mixed_enum_type coverity warning Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 073/103] arm64: mm: Fix ARCH_LOW_ADDRESS_LIMIT when !CONFIG_ZONE_DMA Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 074/103] qed: select CONFIG_CRC32 Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 075/103] phy: dp83640: " Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 076/103] wil6210: " Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 077/103] block: rsxx: " Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 078/103] lightnvm: " Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 079/103] zonefs: " Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 080/103] iommu/vt-d: Fix misuse of ALIGN in qi_flush_piotlb() Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 081/103] iommu/intel: Fix memleak in intel_irq_remapping_alloc Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 082/103] bpftool: Fix compilation failure for net.o with older glibc Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 083/103] nvme-tcp: Fix possible race of io_work and direct send Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 084/103] net/mlx5e: Fix memleak in mlx5e_create_l2_table_groups Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 085/103] net/mlx5e: Fix two double free cases Greg Kroah-Hartman
2021-01-15 12:28 ` Greg Kroah-Hartman [this message]
2021-01-15 20:18   ` [PATCH 5.10 086/103] regmap: debugfs: Fix a memory leak when calling regmap_attach_dev Pavel Machek
2021-01-15 20:22     ` Nathan Chancellor
2021-01-15 20:26     ` Pavel Machek
2021-01-15 12:28 ` [PATCH 5.10 087/103] wan: ds26522: select CONFIG_BITREVERSE Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 088/103] arm64: cpufeature: remove non-exist CONFIG_KVM_ARM_HOST Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 089/103] regulator: qcom-rpmh-regulator: correct hfsmps515 definition Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 090/103] net: mvpp2: disable force link UP during port init procedure Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 091/103] drm/i915/dp: Track pm_qos per connector Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 092/103] net: mvneta: fix error message when MTU too large for XDP Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 093/103] selftests: fib_nexthops: Fix wrong mausezahn invocation Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 094/103] KVM: arm64: Dont access PMCR_EL0 when no PMU is available Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 095/103] xsk: Fix race in SKB mode transmit with shared cq Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 096/103] xsk: Rollback reservation at NETDEV_TX_BUSY Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 097/103] block/rnbd-clt: avoid module unload race with close confirmation Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 098/103] can: isotp: isotp_getname(): fix kernel information leak Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 099/103] block: fix use-after-free in disk_part_iter_next Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 100/103] net: drop bogus skb with CHECKSUM_PARTIAL and offset beyond end of trimmed packet Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 101/103] regmap: debugfs: Fix a reversed if statement in regmap_debugfs_init() Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 102/103] drm/panfrost: Remove unused variables in panfrost_job_close() Greg Kroah-Hartman
2021-01-15 12:28 ` [PATCH 5.10 103/103] tools headers UAPI: Sync linux/fscrypt.h with the kernel sources Greg Kroah-Hartman
2021-01-15 21:13 ` [PATCH 5.10 000/103] 5.10.8-rc1 review Shuah Khan
2021-01-17 13:20   ` Greg Kroah-Hartman
2021-01-15 21:19 ` Guenter Roeck
2021-01-17 13:21   ` Greg Kroah-Hartman
2021-01-16  4:09 ` Naresh Kamboju
2021-01-17 13:21   ` Greg Kroah-Hartman
2021-01-16  7:57 ` Pavel Machek
2021-01-17 13:21   ` Greg Kroah-Hartman
2021-01-18  9:29     ` Pavel Machek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210115122010.175920983@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=xiaolei.wang@windriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).