drm/msm: fix potential memleak in error branch
Subsystems (5)
Sasha Levin
maintainerPATCH 1/8 drm/msm: fix potential memleak in error branch
From: Bernard Zhao <[email protected]>
[ Upstream commit 177d3819633cd520e3f95df541a04644aab4c657 ]
In function msm_submitqueue_create, the queue is a local variable, in return -EINVAL branch, queue didnt add to ctxs list yet, and also didn`t kfree, this maybe bring in potential memleak.
--- drivers/gpu/drm/msm/msm_submitqueue.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/msm_submitqueue.c +3 -1
@@ -78,8 +78,10 @@ int msm_submitqueue_create(struct drm_device *drm, struct msm_file_private *ctx, queue->flags = flags;if (priv->gpu) { -if (prio >= priv->gpu->nr_rings) +if (prio >= priv->gpu->nr_rings) { +kfree (queue);return -EINVAL ; + } queue->prio = prio; }
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 2/8 drm/exynos: fix ref count leak in mic_pre_enable
From: Navid Emamdoost <[email protected]>
[ Upstream commit d4f5a095daf0d25f0b385e1ef26338608433a4c5 ]
in mic_pre_enable, pm_runtime_get_sync is called which increments the counter even in case of failure, leading to incorrect ref count. In case of failure, decrement the ref count before returning.
--- drivers/gpu/drm/exynos/exynos_drm_mic.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/exynos/exynos_drm_mic.c +3 -1
@@ -267,8 +267,10 @@ static void mic_pre_enable(struct drm_bridge *bridge) goto unlock; ret =pm_runtime_get_sync (mic->dev); -if (ret <0 ) +if (ret <0 ) { +pm_runtime_put_noidle (mic->dev); goto unlock; + }mic_set_path (mic,1 );
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 3/8 m68k: nommu: register start of the memory with memblock
In reply to Sasha LevinFrom: Mike Rapoport <[email protected]>
[ Upstream commit d63bd8c81d8ab64db506ffde569cc8ff197516e2 ]
The m68k nommu setup code didn't register the beginning of the physical memory with memblock because it was anyway occupied by the kernel. However, commit fa3354e4ea39 ("mm: free_area_init: use maximal zone PFNs rather than zone sizes") changed zones initialization to use memblock.memory to detect the zone extents and this caused inconsistency between zone PFNs and the actual PFNs:
BUG: Bad page state in process swapper pfn:20165
page:41fe0ca0 refcount:0 mapcount:1 mapping:00000000 index:0x0 flags: 0x0()
raw: 00000000 00000100 00000122 00000000 00000000 00000000 00000000 00000000
page dumped because: nonzero mapcount
CPU: 0 PID: 1 Comm: swapper Not tainted 5.8.0-rc1-00001-g3a38f8a60c65-dirty #1
Stack from 404c9ebc:
404c9ebc 4029ab28 4029ab28 40088470 41fe0ca0 40299e21 40299df1 404ba2a4
00020165 00000000 41fd2c10 402c7ba0 41fd2c04 40088504 41fe0ca0 40299e21
00000000 40088a12 41fe0ca0 41fe0ca4 0000020a 00000000 00000001 402ca000
00000000 41fe0ca0 41fd2c10 41fd2c10 00000000 00000000 402b2388 00000001
400a0934 40091056 404c9f44 404c9f44 40088db4 402c7ba0 00000001 41fd2c04
41fe0ca0 41fd2000 41fe0ca0 40089e02 4026ecf4 40089e4e 41fe0ca0 ffffffff
Call Trace:
[<40088470>] 0x40088470
[<40088504>] 0x40088504
[<40088a12>] 0x40088a12
[<402ca000>] 0x402ca000
[<400a0934>] 0x400a0934Adjust the memory registration with memblock to include the beginning of the physical memory and make sure that the area occupied by the kernel is marked as reserved.
--- arch/m68k/kernel/setup_no.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/m68k/kernel/setup_no.c +2 -1
@@ -140,7 +140,8 @@ void __init setup_arch(char **cmdline_p)pr_debug ("MEMORY -> ROMFS=0x%p-0x%06lx MEM=0x%06lx-0x%06lx\n " , __bss_stop, memory_start, memory_start, memory_end); -memblock_add (memory_start, memory_end - memory_start); +memblock_add (_rambase, memory_end - _rambase); +memblock_reserve (_rambase, memory_start - _rambase);/* Keep a copy of command line */ *cmdline_p = &command_line[0 ];
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 4/8 m68k: mm: fix node memblock init
In reply to Sasha LevinFrom: Angelo Dureghello <[email protected]>
[ Upstream commit c43e55796dd4d13f4855971a4d7970ce2cd94db4 ]
After pulling 5.7.0 (linux-next merge), mcf5441x mmu boot was hanging silently.
memblock_add() seems not appropriate, since using MAX_NUMNODES as node id, while memblock_add_node() sets up memory for node id 0.
--- arch/m68k/mm/mcfmmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/m68k/mm/mcfmmu.c +1 -1
@@ -160,7 +160,7 @@ void __init cf_bootmem_alloc(void) m68k_memory[0 ].addr = _rambase; m68k_memory[0 ].size = _ramend - _rambase; -memblock_add (m68k_memory[0 ].addr, m68k_memory[0 ].size); +memblock_add_node (m68k_memory[0 ].addr, m68k_memory[0 ].size,0 );/* compute total pages in system */ num_pages =PFN_DOWN (_ramend - _rambase);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 5/8 arm64/alternatives: use subsections for replacement sequences
In reply to Sasha LevinFrom: Ard Biesheuvel <[email protected]>
[ Upstream commit f7b93d42945cc71e1346dd5ae07c59061d56745e ]
When building very large kernels, the logic that emits replacement sequences for alternatives fails when relative branches are present in the code that is emitted into the .altinstr_replacement section and patched in at the original site and fixed up. The reason is that the linker will insert veneers if relative branches go out of range, and due to the relative distance of the .altinstr_replacement from the .text section where its branch targets usually live, veneers may be emitted at the end of the .altinstr_replacement section, with the relative branches in the sequence pointed at the veneers instead of the actual target.
The alternatives patching logic will attempt to fix up the branch to point to its original target, which will be the veneer in this case, but given that the patch site is likely to be far away as well, it will be out of range and so patching will fail. There are other cases where these veneers are problematic, e.g., when the target of the branch is in .text while the patch site is in .init.text, in which case putting the replacement sequence inside .text may not help either.
So let's use subsections to emit the replacement code as closely as possible to the patch site, to ensure that veneers are only likely to be emitted if they are required at the patch site as well, in which case they will be in range for the replacement sequence both before and after it is transported to the patch site.
This will prevent alternative sequences in non-init code from being released from memory after boot, but this is tolerable given that the entire section is only 512 KB on an allyesconfig build (which weighs in at 500+ MB for the entire Image). Also, note that modules today carry the replacement sequences in non-init sections as well, and any of those that target init code will be emitted into init sections after this change.
This fixes an early crash when booting an allyesconfig kernel on a system where any of the alternatives sequences containing relative branches are activated at boot (e.g., ARM64_HAS_PAN on TX2)
--- arch/arm64/include/asm/alternative.h | 16 ++++++++-------- arch/arm64/kernel/vmlinux.lds.S | 3 --- 2 files changed, 8 insertions(+), 11 deletions(-)
arch/arm64/include/asm/alternative.h +8 -8
@@ -73,11 +73,11 @@ static inline void apply_alternatives_module(void *start, size_t length) { }".pushsection .altinstructions,\"a\"\n" \ ALTINSTR_ENTRY(feature) \".popsection\n" \ -".pushsection .altinstr_replacement, \"a\"\n" \ +".subsection 1\n" \"663:\n\t" \ newinstr"\n" \"664:\n\t" \ -".popsection\n\t" \ +".previous\n\t" \".org . - (664b-663b) + (662b-661b)\n\t" \".org . - (662b-661b) + (664b-663b)\n" \".endif\n"
@@ -117,9 +117,9 @@ static inline void apply_alternatives_module(void *start, size_t length) { } 662: .pushsection .altinstructions, "a" altinstruction_entry 661b, 663f, \cap, 662b-661b, 664f-663f .popsection - .pushsection .altinstr_replacement,"ax" + .subsection 1 663: \insn2 -664: .popsection +664: .previous .org . - (664b-663b) + (662b-661b) .org . - (662b-661b) + (664b-663b) .endif
@@ -160,7 +160,7 @@ static inline void apply_alternatives_module(void *start, size_t length) { } .pushsection .altinstructions, "a" altinstruction_entry 663f, 661f, \cap, 664f-663f, 662f-661f .popsection - .pushsection .altinstr_replacement, "ax" + .subsection 1 .align 2 /* So GAS knows label 661 is suitably aligned */ 661: .endm
@@ -179,9 +179,9 @@ static inline void apply_alternatives_module(void *start, size_t length) { } .macro alternative_else 662: .if .Lasm_alt_mode==0 - .pushsection .altinstr_replacement,"ax" + .subsection 1 .else - .popsection + .previous .endif 663: .endm
@@ -192,7 +192,7 @@ static inline void apply_alternatives_module(void *start, size_t length) { } .macro alternative_endif 664: .if .Lasm_alt_mode==0 - .popsection + .previous .endif .org . - (664b-663b) + (662b-661b) .org . - (662b-661b) + (664b-663b)
arch/arm64/kernel/vmlinux.lds.S +0 -3
@@ -154,9 +154,6 @@ SECTIONS *(.altinstructions) __alt_instructions_end = .; } - .altinstr_replacement : { - *(.altinstr_replacement) - } . = ALIGN(PAGE_SIZE); __inittext_end = .;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 6/8 tpm_tis: extra chip->ops check on error path in tpm_tis_core_init
In reply to Sasha LevinFrom: Vasily Averin <[email protected]>
[ Upstream commit ccf6fb858e17a8f8a914a1c6444d277cfedfeae6 ]
Found by smatch:drivers/char/tpm/tpm_tis_core.c:1088 tpm_tis_core_init() warn:
variable dereferenced before check 'chip->ops' (see line 979)
'chip->ops' is assigned in the beginning of function in tpmm_chip_alloc->tpm_chip_alloc
and is used before first possible goto to error path.
--- drivers/char/tpm/tpm_tis_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/tpm_tis_core.c +1 -1
@@ -1007,7 +1007,7 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,return 0 ; out_err: -if ((chip->ops !=NULL ) && (chip->ops->clk_enable !=NULL )) +if (chip->ops->clk_enable !=NULL ) chip->ops->clk_enable (chip, false);tpm_tis_remove (chip);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 7/8 gfs2: read-only mounts should grab the sd_freeze_gl glock
In reply to Sasha LevinFrom: Bob Peterson <[email protected]>
[ Upstream commit b780cc615ba4795a7ef0e93b19424828a5ad456a ]
Before this patch, only read-write mounts would grab the freeze glock in read-only mode, as part of gfs2_make_fs_rw. So the freeze glock was never initialized. That meant requests to freeze, which request the glock in EX, were granted without any state transition. That meant you could mount a gfs2 file system, which is currently frozen on a different cluster node, in read-only mode.
This patch makes read-only mounts lock the freeze glock in SH mode, which will block for file systems that are frozen on another node.
--- fs/gfs2/ops_fstype.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
fs/gfs2/ops_fstype.c +11 -1
@@ -1160,7 +1160,17 @@ static int fill_super(struct super_block *sb, struct gfs2_args *args, int silent goto fail_per_node; } -if (!sb_rdonly (sb)) { +if (sb_rdonly (sb)) { +struct gfs2_holder freeze_gh; + + error =gfs2_glock_nq_init (sdp->sd_freeze_gl,LM_ST_SHARED , +GL_EXACT , &freeze_gh); +if (error) { +fs_err (sdp,"can't make FS RO: %d\n" , error); + goto fail_per_node; + } +gfs2_glock_dq_uninit (&freeze_gh); + }else { error =gfs2_make_fs_rw (sdp);if (error) {fs_err (sdp,"can't make FS RW: %d\n" , error);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 8/8 i2c: eg20t: Load module automatically if ID matches
In reply to Sasha LevinFrom: Andy Shevchenko <[email protected]>
[ Upstream commit 5f90786b31fb7d1e199a8999d46c4e3aea672e11 ]
The driver can't be loaded automatically because it misses module alias to be provided. Add corresponding MODULE_DEVICE_TABLE() call to the driver.
--- drivers/i2c/busses/i2c-eg20t.c | 1 + 1 file changed, 1 insertion(+)
drivers/i2c/busses/i2c-eg20t.c +1 -0
@@ -188,6 +188,7 @@ static const struct pci_device_id pch_pcidev_id[] = { { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7831_I2C), 1, }, {0,} }; +MODULE_DEVICE_TABLE (pci, pch_pcidev_id);static irqreturn_t pch_i2c_handler (int irq,void *pData);
Signature · 1 line
2.25.1