From 9bfb3c8db02c848097a9fa1a2d4560e7d5b89853 Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Mon, 16 Nov 2020 08:58:18 -0500 Subject: [PATCH] Fixes for 4.4 Signed-off-by: Sasha Levin --- ...ng-kfree-in-error-path-of-cosa_write.patch | 39 +++++++++++++++ ...f_node-memory-leak-in-of_dma_is_cohe.patch | 47 +++++++++++++++++++ .../perf-fix-get_recursion_context.patch | 35 ++++++++++++++ queue-4.4/series | 4 ++ ...g-unlock-on-error-in-xfs_fs_map_bloc.patch | 37 +++++++++++++++ 5 files changed, 162 insertions(+) create mode 100644 queue-4.4/cosa-add-missing-kfree-in-error-path-of-cosa_write.patch create mode 100644 queue-4.4/of-address-fix-of_node-memory-leak-in-of_dma_is_cohe.patch create mode 100644 queue-4.4/perf-fix-get_recursion_context.patch create mode 100644 queue-4.4/xfs-fix-a-missing-unlock-on-error-in-xfs_fs_map_bloc.patch diff --git a/queue-4.4/cosa-add-missing-kfree-in-error-path-of-cosa_write.patch b/queue-4.4/cosa-add-missing-kfree-in-error-path-of-cosa_write.patch new file mode 100644 index 00000000000..26c7742e72d --- /dev/null +++ b/queue-4.4/cosa-add-missing-kfree-in-error-path-of-cosa_write.patch @@ -0,0 +1,39 @@ +From 9990b46f80c8e7899ed81cb8eb1e9532862ae2af Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 10 Nov 2020 22:46:14 +0800 +Subject: cosa: Add missing kfree in error path of cosa_write + +From: Wang Hai + +[ Upstream commit 52755b66ddcef2e897778fac5656df18817b59ab ] + +If memory allocation for 'kbuf' succeed, cosa_write() doesn't have a +corresponding kfree() in exception handling. Thus add kfree() for this +function implementation. + +Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") +Reported-by: Hulk Robot +Signed-off-by: Wang Hai +Acked-by: Jan "Yenya" Kasprzak +Link: https://lore.kernel.org/r/20201110144614.43194-1-wanghai38@huawei.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Sasha Levin +--- + drivers/net/wan/cosa.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c +index 848ea6a399f23..cbda69e58e084 100644 +--- a/drivers/net/wan/cosa.c ++++ b/drivers/net/wan/cosa.c +@@ -903,6 +903,7 @@ static ssize_t cosa_write(struct file *file, + chan->tx_status = 1; + spin_unlock_irqrestore(&cosa->lock, flags); + up(&chan->wsem); ++ kfree(kbuf); + return -ERESTARTSYS; + } + } +-- +2.27.0 + diff --git a/queue-4.4/of-address-fix-of_node-memory-leak-in-of_dma_is_cohe.patch b/queue-4.4/of-address-fix-of_node-memory-leak-in-of_dma_is_cohe.patch new file mode 100644 index 00000000000..b5ee6f916a4 --- /dev/null +++ b/queue-4.4/of-address-fix-of_node-memory-leak-in-of_dma_is_cohe.patch @@ -0,0 +1,47 @@ +From 931610393a561476b32a25fd631416fcc30fc60d Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 10 Nov 2020 15:28:25 +1300 +Subject: of/address: Fix of_node memory leak in of_dma_is_coherent + +From: Evan Nimmo + +[ Upstream commit a5bea04fcc0b3c0aec71ee1fd58fd4ff7ee36177 ] + +Commit dabf6b36b83a ("of: Add OF_DMA_DEFAULT_COHERENT & select it on +powerpc") added a check to of_dma_is_coherent which returns early +if OF_DMA_DEFAULT_COHERENT is enabled. This results in the of_node_put() +being skipped causing a memory leak. Moved the of_node_get() below this +check so we now we only get the node if OF_DMA_DEFAULT_COHERENT is not +enabled. + +Fixes: dabf6b36b83a ("of: Add OF_DMA_DEFAULT_COHERENT & select it on powerpc") +Signed-off-by: Evan Nimmo +Link: https://lore.kernel.org/r/20201110022825.30895-1-evan.nimmo@alliedtelesis.co.nz +Signed-off-by: Rob Herring +Signed-off-by: Sasha Levin +--- + drivers/of/address.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/drivers/of/address.c b/drivers/of/address.c +index b3bf8762f4e8c..77881432dd404 100644 +--- a/drivers/of/address.c ++++ b/drivers/of/address.c +@@ -1014,11 +1014,13 @@ EXPORT_SYMBOL_GPL(of_dma_get_range); + */ + bool of_dma_is_coherent(struct device_node *np) + { +- struct device_node *node = of_node_get(np); ++ struct device_node *node; + + if (IS_ENABLED(CONFIG_OF_DMA_DEFAULT_COHERENT)) + return true; + ++ node = of_node_get(np); ++ + while (node) { + if (of_property_read_bool(node, "dma-coherent")) { + of_node_put(node); +-- +2.27.0 + diff --git a/queue-4.4/perf-fix-get_recursion_context.patch b/queue-4.4/perf-fix-get_recursion_context.patch new file mode 100644 index 00000000000..f4f3005080c --- /dev/null +++ b/queue-4.4/perf-fix-get_recursion_context.patch @@ -0,0 +1,35 @@ +From 455aea3ea3e9b2961978f1128ad8ee209bc11957 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 30 Oct 2020 12:49:45 +0100 +Subject: perf: Fix get_recursion_context() + +From: Peter Zijlstra + +[ Upstream commit ce0f17fc93f63ee91428af10b7b2ddef38cd19e5 ] + +One should use in_serving_softirq() to detect SoftIRQ context. + +Fixes: 96f6d4444302 ("perf_counter: avoid recursion") +Signed-off-by: Peter Zijlstra (Intel) +Link: https://lkml.kernel.org/r/20201030151955.120572175@infradead.org +Signed-off-by: Sasha Levin +--- + kernel/events/internal.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/kernel/events/internal.h b/kernel/events/internal.h +index 2bbad9c1274c3..8baa3121e7a6b 100644 +--- a/kernel/events/internal.h ++++ b/kernel/events/internal.h +@@ -193,7 +193,7 @@ static inline int get_recursion_context(int *recursion) + rctx = 3; + else if (in_irq()) + rctx = 2; +- else if (in_softirq()) ++ else if (in_serving_softirq()) + rctx = 1; + else + rctx = 0; +-- +2.27.0 + diff --git a/queue-4.4/series b/queue-4.4/series index 0786a2bf97c..7fdd81f483a 100644 --- a/queue-4.4/series +++ b/queue-4.4/series @@ -25,3 +25,7 @@ mac80211-fix-use-of-skb-payload-instead-of-header.patch mac80211-always-wind-down-sta-state.patch cfg80211-regulatory-fix-inconsistent-format-argument.patch iommu-amd-increase-interrupt-remapping-table-limit-t.patch +xfs-fix-a-missing-unlock-on-error-in-xfs_fs_map_bloc.patch +of-address-fix-of_node-memory-leak-in-of_dma_is_cohe.patch +cosa-add-missing-kfree-in-error-path-of-cosa_write.patch +perf-fix-get_recursion_context.patch diff --git a/queue-4.4/xfs-fix-a-missing-unlock-on-error-in-xfs_fs_map_bloc.patch b/queue-4.4/xfs-fix-a-missing-unlock-on-error-in-xfs_fs_map_bloc.patch new file mode 100644 index 00000000000..a5827db6f96 --- /dev/null +++ b/queue-4.4/xfs-fix-a-missing-unlock-on-error-in-xfs_fs_map_bloc.patch @@ -0,0 +1,37 @@ +From 190d001b198ae93e00dc7682819e884f0b7d36f8 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 11 Nov 2020 08:07:37 -0800 +Subject: xfs: fix a missing unlock on error in xfs_fs_map_blocks + +From: Christoph Hellwig + +[ Upstream commit 2bd3fa793aaa7e98b74e3653fdcc72fa753913b5 ] + +We also need to drop the iolock when invalidate_inode_pages2 fails, not +only on all other error or successful cases. + +Fixes: 527851124d10 ("xfs: implement pNFS export operations") +Signed-off-by: Christoph Hellwig +Reviewed-by: Darrick J. Wong +Signed-off-by: Darrick J. Wong +Signed-off-by: Sasha Levin +--- + fs/xfs/xfs_pnfs.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/fs/xfs/xfs_pnfs.c b/fs/xfs/xfs_pnfs.c +index dc6221942b85f..ab66ea0a72bfb 100644 +--- a/fs/xfs/xfs_pnfs.c ++++ b/fs/xfs/xfs_pnfs.c +@@ -162,7 +162,7 @@ xfs_fs_map_blocks( + goto out_unlock; + error = invalidate_inode_pages2(inode->i_mapping); + if (WARN_ON_ONCE(error)) +- return error; ++ goto out_unlock; + + end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + length); + offset_fsb = XFS_B_TO_FSBT(mp, offset); +-- +2.27.0 + -- 2.47.3