6.6.163-rc1 review
Subsystems (6)
Greg Kroah-Hartman
maintainerPATCH 1996/3318 ARM: dts: armada-385-clearfog-gtr: fix vmmc property name
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 337d10963f601d5a3dfb4b7aa273ca8c0b4d5172 ]
The SDHCI node references the 3.3V regulator through a bare "vmmc" property, which is not part of the mmc controller DT binding; the correct property is "vmmc-supply".
--- arch/arm/boot/dts/marvell/armada-385-clearfog-gtr.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/marvell/armada-385-clearfog-gtr.dtsi +1 -1
@@ -202,7 +202,7 @@ sdhci@d8000 { pinctrl-0 = <&cf_gtr_sdhci_pins>; pinctrl-names = "default"; status = "okay"; - vmmc = <®_3p3v>; + vmmc-supply = <®_3p3v>; wp-inverted; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1997/3318 ARM: dts: armada-395-gp: drop unsupported SDHCI clock-frequency
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit a56183c7f15215d804290808a2b5a1fa997aa9cd ]
The SDHCI node carries a "clock-frequency" property, but the marvell,armada-380-sdhci binding does not define it and dtbs_check rejects the node as a result. No driver consumes it either: only a few other sdhci-pltfm based drivers (imx, mcf, iproc, arasan, dwcmshc, xenon) read that property, while sdhci-pxav3 derives the maximum clock from the io clock rate.
Remove the property.
--- arch/arm/boot/dts/marvell/armada-395-gp.dts | 1 - 1 file changed, 1 deletion(-)
arch/arm/boot/dts/marvell/armada-395-gp.dts +0 -1
@@ -59,7 +59,6 @@ sata@a8000 { /* CON18 */ sdhci@d8000 { - clock-frequency = <200000000>; broken-cd; wp-inverted; bus-width = <8>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1998/3318 ARM: dts: armada-388-helios4: fix vmmc property name
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 008e9faadef8c0aaa9b8a3ff05a2126e3c5b08b7 ]
The sdhci@d8000 node references the 3.3V regulator through a bare "vmmc" property, which is not part of the mmc controller DT binding. The binding requires supply properties in the form "vmmc-supply", so the current entry is ignored by the driver.
Rename the property to "vmmc-supply" so the fixed regulator is correctly wired up as the card power supply.
--- arch/arm/boot/dts/marvell/armada-388-helios4.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/marvell/armada-388-helios4.dts +1 -1
@@ -269,7 +269,7 @@ sdhci@d8000 { &helios_sdhci_cd_pins>; pinctrl-names = "default"; status = "okay"; - vmmc = <®_3p3v>; + vmmc-supply = <®_3p3v>; wp-inverted; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1999/3318 ARM: dts: helios4: fix vbus-supply for USB2 PHY
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit a132798a133e76a7bb575ba95b2b64eadd245438 ]
The usb-nop-xceiv binding and driver use "vbus-supply"; the driver acquires the VBUS regulator via devm_regulator_get_exclusive("vbus") (phy-generic.c). The stale "vbus-regulator" name is never read by the driver and dtbs_check rejects it as an unknown property. Rename the property so reg_5p0v_usb is honored.
--- arch/arm/boot/dts/marvell/armada-388-helios4.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/marvell/armada-388-helios4.dts +1 -1
@@ -140,7 +140,7 @@ fan2: j17-pwm { usb2_phy: usb2-phy { compatible = "usb-nop-xceiv"; - vbus-regulator = <®_5p0v_usb>; + vbus-supply = <®_5p0v_usb>; }; usb3_phy: usb3-phy {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2000/3318 ARM: dts: helios4: fix spi1 location
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 5df4320a30a87f9bb918ace7b389026917c8d896 ]
This spi node is specified in armada-38x.dtsi with proper compatible strings whereas they are not present here. Instead of copy and pasting various lines, just reference the node in the dtsi.
This dts seems to predate the move of spi from internal-regs to the soc node so this moves it in line there.
Allows proper probing of SPI at runtime.
Remove the microsom_spi1_cs_pins pinctrl group and its reference in &spi1. The group only muxed mpp59 to the "spi1" function, but that pin (SPI1 cs0) is already covered by spi1_pins, which selects the same function for mpp56-59 in armada-38x.dtsi.
--- .../arm/boot/dts/marvell/armada-388-helios4.dts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
arch/arm/boot/dts/marvell/armada-388-helios4.dts +6 -11
@@ -254,13 +254,6 @@ sata3: sata-port@1 { }; }; - spi@10680 { - pinctrl-0 = <&spi1_pins - µsom_spi1_cs_pins>; - pinctrl-names = "default"; - status = "okay"; - }; - sdhci@d8000 { bus-width = <4>; cd-gpios = <&gpio0 20 GPIO_ACTIVE_LOW>;
@@ -327,11 +320,13 @@ helios_fan2_pins: helios_fan2_pins { marvell,pins = "mpp48", "mpp55"; marvell,function = "gpio"; }; - microsom_spi1_cs_pins: spi1-cs-pins { - marvell,pins = "mpp59"; - marvell,function = "spi1"; - }; }; }; }; }; + +&spi1 { + pinctrl-0 = <&spi1_pins>; + pinctrl-names = "default"; + status = "okay"; +};
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2001/3318 kexec_file: stop the top-down search before it underflows
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
[ Upstream commit c711461303af9f796b293b5ac06f49a885e46e71 ]
locate_mem_hole_top_down() walks candidates downwards by subtracting PAGE_SIZE whenever the window conflicts with an existing segment or with an architecture exclude range.
Nothing stops that subtraction at zero, so a search that reaches the bottom of the address space wraps temp_start around and continues.
The walk starts inside the range being scanned and only moves down, so bail out once a candidate ends up above end. That covers every step in the loop rather than the subtractions alone, and it matches locate_mem_hole_bottom_up(), which already bounds its candidate on both sides.
This is a better check than subtracting with check_sub_overflow(), given that we would have 3 subtractions in this block, and this single fix would take care of them all (instead of three check_sub_overflow()).
--- kernel/kexec_file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/kexec_file.c +3 -1
@@ -432,7 +432,9 @@ static int locate_mem_hole_top_down(unsigned long start, unsigned long end,/* align down start */ temp_start = temp_start & (~(kbuf->buf_align -1 )); -if (temp_start < start || temp_start < kbuf->buf_min) +/* A candidate above the range means the walk wrapped around */ +if (temp_start < start || temp_start < kbuf->buf_min || + temp_start > end)return 0 ; temp_end = temp_start + kbuf->memsz -1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2002/3318 perf jitdump: Fix extended header read that always fails
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit 598e905931380f0714d5fd50cecfac615a1ec742 ]
jit_open() sets bsz = bs before the fread() that uses bs - bsz as the read size, making the expression always evaluate to zero. fread() with size 0 returns 0, which triggers the ret != 1 error path — so extended jitdump headers (total_size > sizeof(header)) have been silently broken since the original implementation.
Additionally, when 0 < bs <= bsz the if (bs > bsz) block is skipped entirely, leaving extended header bytes unread in the stream. Subsequent jit_get_next_entry() calls then parse those leftover bytes as a jr_prefix, corrupting the record stream.
Fix by separating the buffer growth from the read: realloc only when bs > bsz, then unconditionally fread bs bytes when bs > 0.
--- tools/perf/util/jitdump.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
tools/perf/util/jitdump.c +5 -3
@@ -223,10 +223,12 @@ jit_open(struct jit_buf_desc *jd, const char *name) n =realloc (buf, bs);if (!n) goto error; - bsz = bs; buf = n; -/* read extra we do not know about */ - ret =fread (buf, bs - bsz,1 , jd->in); + bsz = bs; + } +if (bs >0 ) { +/* consume extended header bytes from the stream */ + ret =fread (buf, bs,1 , jd->in);if (ret !=1 ) goto error; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2003/3318 perf jitdump: Fix debug_data and unwinding_data leaks
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit 2bd967f3adcba1d3e54f10b0d8b25f950e4f03fd ]
jit_repipe_debug_info() overwrites jd->debug_data without freeing the previous allocation. If two consecutive JIT_CODE_DEBUG_INFO records appear without an intervening LOAD record consuming the data, the first allocation leaks.
The sibling jit_repipe_unwinding_info() already frees the old jd->unwinding_data before reassignment — add the same pattern to jit_repipe_debug_info() using zfree().
Also add cleanup of both buffers in jit_close() so they are freed when the jitdump session ends, even if no LOAD record consumed them.
--- tools/perf/util/jitdump.c | 3 +++ 1 file changed, 3 insertions(+)
tools/perf/util/jitdump.c +3 -0
@@ -116,6 +116,8 @@ jit_close(struct jit_buf_desc *jd)funlockfile (jd->in);fclose (jd->in); jd->in =NULL ; +zfree (&jd->debug_data); +zfree (&jd->unwinding_data); } static int
@@ -646,6 +648,7 @@ static int jit_repipe_debug_info(struct jit_buf_desc *jd, union jr_entry *jr)memcpy (data, &jr->info.entries, sz); +zfree (&jd->debug_data); jd->debug_data = data;/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2004/3318 perf jitdump: Validate code_size against total_size in code load
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit 06c7cf7a072fcd52e68471628c56630d2bdcc650 ]
jit_repipe_code_load() reads code_size from the jitdump record and uses it to compute a pointer to the code blob:
code = (unsigned long)jr + jr->load.p.total_size - csize;
An oversized code_size underflows the pointer arithmetic, causing OOB reads into earlier heap memory. Validate that code_size fits within the record (total_size - sizeof(jr->load)) before the pointer computation.
code_size is uint64_t but csize is int; values above INT_MAX wrap negative when narrowed into csize, which defeats the bounds check and sends the code pointer past the end of the record. Reject those too.
--- tools/perf/util/jitdump.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
tools/perf/util/jitdump.c +11 -0
@@ -9,6 +9,7 @@#include <fcntl.h> #include <unistd.h> #include <inttypes.h> +#include <limits.h> #include <byteswap.h> #include <sys/stat.h> #include <sys/mman.h>
@@ -450,6 +451,16 @@ static int jit_repipe_code_load(struct jit_buf_desc *jd, union jr_entry *jr) csize = jr->load.code_size; usize = jd->unwinding_mapped_size; addr = jr->load.code_addr; + +/* code blob lives at the end of the record, validate it fits */ +if (jr->load.p.total_size <sizeof (jr->load) || + jr->load.code_size > jr->load.p.total_size -sizeof (jr->load) || + jr->load.code_size >INT_MAX ) { +pr_warning ("jitdump: invalid code_size %" PRIu64" (total_size=%u) in code_load record\n" , + (uint64_t )jr->load.code_size, jr->load.p.total_size); +return -1 ; + } + sym = (void *)((unsigned long )jr +sizeof (jr->load)); code = (unsigned long )jr + jr->load.p.total_size - csize; count = jr->load.code_index;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2005/3318 perf jitdump: Prevent integer underflow in debug info size calculation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit dfe8fe96efca3c32979dc0859f88e15b677d25f1 ]
jit_repipe_debug_info() and jit_repipe_unwinding_info() compute payload sizes by subtracting the fixed header size from total_size:
sz = jr->prefix.total_size - sizeof(jr->info);
When total_size is smaller than the header struct (from a truncated or corrupted jitdump record), the subtraction underflows to a massive value, causing an oversized allocation followed by an OOB memcpy.
Validate that total_size covers at least the fixed header before the subtraction in both functions.
--- tools/perf/util/jitdump.c | 8 ++++++++ 1 file changed, 8 insertions(+)
tools/perf/util/jitdump.c +8 -0
@@ -652,6 +652,10 @@ static int jit_repipe_debug_info(struct jit_buf_desc *jd, union jr_entry *jr)if (!(jd && jr))return -1 ; +/* total_size must cover at least the fixed header */ +if (jr->prefix.total_size <sizeof (jr->info)) +return -1 ; + sz = jr->prefix.total_size -sizeof (jr->info); data =malloc (sz);if (!data)
@@ -680,6 +684,10 @@ jit_repipe_unwinding_info(struct jit_buf_desc *jd, union jr_entry *jr)if (!(jd && jr))return -1 ; +/* total_size must cover at least the fixed header */ +if (jr->prefix.total_size <sizeof (jr->unwinding)) +return -1 ; + unwinding_data_size = jr->prefix.total_size -sizeof (jr->unwinding); unwinding_data =malloc (unwinding_data_size);if (!unwinding_data)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2006/3318 perf jitdump: Bounds-check debug entry byte-swap loop
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit ede3cd8151675c2983cd49104b1e9b25a3712ed8 ]
The byte-swap loop for JIT_CODE_DEBUG_INFO uses array indexing (jr->info.entries[n]) to iterate debug entries. struct debug_entry has a flexible array member name[], so each entry has a different size. Array indexing computes offsets assuming fixed-size elements, landing inside variable-length name strings after the first entry and byte-swapping garbage.
Additionally, nr_entry is read from untrusted jitdump input without validation against total_size, so a crafted value causes OOB reads.
Replace the array indexing with debug_entry_next() pointer arithmetic (which correctly accounts for the variable-length name) and bounds-check each entry against the record's total_size before byte-swapping.
--- tools/perf/util/jitdump.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-)
tools/perf/util/jitdump.c +22 -4
@@ -318,14 +318,32 @@ jit_get_next_entry(struct jit_buf_desc *jd)switch (id) {case JIT_CODE_DEBUG_INFO :if (jd->needs_bswap) { +void *end = (void *)jr + jr->prefix.total_size; +struct debug_entry *ent;uint64_t n; + jr->info.code_addr =bswap_64 (jr->info.code_addr); jr->info.nr_entry =bswap_64 (jr->info.nr_entry); -for (n =0 ; n < jr->info.nr_entry; n++) { - jr->info.entries[n].addr =bswap_64 (jr->info.entries[n].addr); - jr->info.entries[n].lineno =bswap_32 (jr->info.entries[n].lineno); - jr->info.entries[n].discrim =bswap_32 (jr->info.entries[n].discrim); + +/* +* debug_entry has a variable-length name[], so array +* indexing would compute wrong offsets — use +* debug_entry_next() and bounds-check each entry. +*/ + ent = &jr->info.entries[0 ]; +for (n =0 ; n < jr->info.nr_entry; n++) { +if ((void *)ent +sizeof (*ent) > end) +break ; +/* name must be NUL-terminated within the record */ +if (!memchr (ent->name,'\0' , (char *)end - ent->name)) +break ; + ent->addr =bswap_64 (ent->addr); + ent->lineno =bswap_32 (ent->lineno); + ent->discrim =bswap_32 (ent->discrim); + ent =debug_entry_next (ent); } +/* clamp so downstream consumers don't overrun */ + jr->info.nr_entry = n; }break ;case JIT_CODE_UNWINDING_INFO :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2007/3318 perf jitdump: Check snprintf return before computing header size
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit 0155f05ea6e133c18a04b8b5945cac59870da156 ]
snprintf() returns the would-have-been length on truncation. When the jitted filename exceeds PATH_MAX, the unclamped 'size' value inflates sizeof(event->mmap2.filename) - size into a massive underflow, causing the header.size computation to write an oversized header. The subsequent write to 'id = event + header.size - idr_size' then corrupts the heap.
Clamp size to PATH_MAX - 1 after snprintf in both jit_repipe_code_load() and jit_repipe_code_move().
--- tools/perf/util/jitdump.c | 6 ++++++ 1 file changed, 6 insertions(+)
tools/perf/util/jitdump.c +6 -0
@@ -493,6 +493,9 @@ static int jit_repipe_code_load(struct jit_buf_desc *jd, union jr_entry *jr) jd->dir, nspid, count); +/* snprintf returns would-be length on truncation, clamp to buffer */ +if (size >=sizeof (event->mmap2.filename)) + size =sizeof (event->mmap2.filename) -1 ; size++;/* for \0 */
@@ -607,6 +610,9 @@ static int jit_repipe_code_move(struct jit_buf_desc *jd, union jr_entry *jr) jd->dir, nspid, jr->move.code_index); +/* snprintf returns would-be length on truncation, clamp to buffer */ +if (size >=sizeof (event->mmap2.filename)) + size =sizeof (event->mmap2.filename) -1 ; size++;/* for \0 */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2008/3318 perf jitdump: Fix funlockfile on unlocked stream in jit_open() error path
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit bfde6848c1e24fd979d0138c57c1cc28c35093c3 ]
If the malloc() for the initial read buffer fails, jit_open() jumps to the error label which calls funlockfile(jd->in). However, flockfile() is called later in the function, so at this point the stream was never locked. Calling funlockfile() on an unlocked stream is undefined behavior per POSIX.
Split the error path into two labels: 'error' (after flockfile) calls funlockfile before cleanup, 'error_noflock' (before flockfile) skips the unlock.
--- tools/perf/util/jitdump.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tools/perf/util/jitdump.c +3 -2
@@ -156,7 +156,7 @@ jit_open(struct jit_buf_desc *jd, const char *name) buf =malloc (bsz);if (!buf) - goto error; + goto error_noflock;/* * protect from writer modifying the file while we are reading it
@@ -244,8 +244,9 @@ jit_open(struct jit_buf_desc *jd, const char *name)return 0 ; error: -free (buf);funlockfile (jd->in); +error_noflock: +free (buf);fclose (jd->in);return retval; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2009/3318 perf: replace strcpy() with strncpy() in util/jitdump.c
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hrishikesh Suresh <[email protected]>
[ Upstream commit 9bef5cead63d5d8fad3ba7ebaf26f3f4ee172c82 ]
Usage of strcpy() can lead to buffer overflows. Therefore, it has been replaced with strncpy(). The output file path is provided as a parameter and might be restricted by command-line by default. But this defensive patch will prevent any potential overflow, making the code more robust against future changes in input handling.
Testing:
- ran perf test from tools/perf and did not observe any regression with the earlier code
Stable-dep-of: 4eddf7d9e341 ("perf jitdump: Use dirname() return value in jit_open()")
--- tools/perf/util/jitdump.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/jitdump.c +2 -1
@@ -238,7 +238,8 @@ jit_open(struct jit_buf_desc *jd, const char *name)/* * keep dirname for generating files and mmap records */ -strcpy (jd->dir, name); +strncpy (jd->dir, name,PATH_MAX ); + jd->dir[PATH_MAX -1 ] ='\0' ;dirname (jd->dir);free (buf);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2010/3318 perf jitdump: Use dirname() return value in jit_open()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit 4eddf7d9e341eb8c41704b8aa27b4a91f4e2c7c9 ]
jit_open() calls dirname(jd->dir) but ignores the return value. POSIX says dirname() may return a pointer to internal static storage — glibc does this when the path has no '/', returning "." from a static buffer and leaving jd->dir unchanged with the original filename.
Capture the return value and copy it back to jd->dir when dirname() returns a different pointer.
--- tools/perf/util/jitdump.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/perf/util/jitdump.c +4 -1
@@ -145,6 +145,7 @@ jit_open(struct jit_buf_desc *jd, const char *name)ssize_t bs, bsz =0 ;void *n, *buf =NULL ;int ret, retval =-1 ; +char *dname;nsinfo__mountns_enter (jd->nsi, &nsc); jd->in =fopen (name,"r" );
@@ -240,7 +241,9 @@ jit_open(struct jit_buf_desc *jd, const char *name)*/ strncpy (jd->dir, name,PATH_MAX ); jd->dir[PATH_MAX -1 ] ='\0' ; -dirname (jd->dir); + dname =dirname (jd->dir); +if (dname != jd->dir) +strlcpy (jd->dir, dname,sizeof (jd->dir));free (buf);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2011/3318 perf jitdump: Validate debug entries on native (non-swap) path
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit 51e14e495f0cea061bbad33e7635f7fd857113ad ]
The bounds-checking and nr_entry clamping added for the byte-swap path only runs when jd->needs_bswap is true. On native-endian files, nr_entry passes through unvalidated to jit_repipe_debug_info(), which stores it as jd->nr_debug_entries. Downstream, jit_process_debug_info() in genelf_debug.c iterates nr_debug_entries times via debug_entry_next(), which calls strlen() on each entry's name field — a crafted nr_entry causes OOB reads and writes.
Add bounds-checked iteration in jit_repipe_debug_info() that validates each debug_entry fits in the payload and its name is NUL-terminated before calling debug_entry_next(). Clamp nr_debug_entries to the count of valid entries.
--- tools/perf/util/jitdump.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-)
tools/perf/util/jitdump.c +22 -5
@@ -675,8 +675,10 @@ static int jit_repipe_code_move(struct jit_buf_desc *jd, union jr_entry *jr)static int jit_repipe_debug_info (struct jit_buf_desc *jd,union jr_entry *jr) { -void *data; -size_t sz; +struct debug_entry *ent; +void *data, *end; +size_t sz, valid; +uint64_t i;if (!(jd && jr))return -1 ;
@@ -696,10 +698,25 @@ static int jit_repipe_debug_info(struct jit_buf_desc *jd, union jr_entry *jr) jd->debug_data = data;/* -* we must use nr_entry instead of size here because -* we cannot distinguish actual entry from padding otherwise +* Clamp nr_debug_entries to entries that actually fit in the +* payload. The byte-swap path already does this for cross-endian +* files; validate on the native path too, since downstream +* jit_process_debug_info() iterates via debug_entry_next() which +* calls strlen() on each entry's name field. */ - jd->nr_debug_entries = jr->info.nr_entry; + end = data + sz; + ent = data; + valid =0 ; +for (i =0 ; i < jr->info.nr_entry; i++) { +if ((void *)ent +sizeof (*ent) > end) +break ; +/* name must be NUL-terminated within the payload */ +if (!memchr (ent->name,'\0' , (char *)end - ent->name)) +break ; + ent =debug_entry_next (ent); + valid++; + } + jd->nr_debug_entries = valid;return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2012/3318 perf jitdump: Validate sym string NUL-termination in code load
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit 98bfe1142ccbaa5ffdca5dcdddd26f238ad33585 ]
jit_repipe_code_load() computes sym = (void *)jr + sizeof(jr->load) and passes it to jit_emit_elf() which calls strlen(sym) via jit_write_elf(). If code_size equals total_size - sizeof(jr->load), the sym pointer aliases the code blob with no NUL terminator, and strlen() scans past the buffer into adjacent heap memory.
Add a memchr() check to verify the symbol name is NUL-terminated within the region between the load header and the code blob before use.
--- tools/perf/util/jitdump.c | 7 +++++++ 1 file changed, 7 insertions(+)
tools/perf/util/jitdump.c +7 -0
@@ -486,6 +486,13 @@ static int jit_repipe_code_load(struct jit_buf_desc *jd, union jr_entry *jr) sym = (void *)((unsigned long )jr +sizeof (jr->load)); code = (unsigned long )jr + jr->load.p.total_size - csize; + +/* sym string lives between the load header and the code blob */ +if (!memchr (sym,'\0' , code - (unsigned long )sym)) { +pr_warning ("jitdump: unterminated symbol name in code_load record\n" ); +return -1 ; + } + count = jr->load.code_index; idr_size = jd->machine->id_hdr_size;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2013/3318 perf jitdump: Validate unwinding sizes against record payload
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit 92d50319b4f0c0bbee8a236a09063272cd22faab ]
jit_repipe_unwinding_info() copies unwinding_size and eh_frame_hdr_size from the jitdump record into jd-> fields without checking them against the actual payload size. Downstream, jit_add_eh_frame_info() in genelf.c computes unwinding_table_size = unwinding_size - eh_frame_hdr_size, which underflows when eh_frame_hdr_size > unwinding_size. The result is passed as d->d_size to libelf, causing an OOB heap read into the output ELF file.
Validate that unwinding_size fits within the record payload and that eh_frame_hdr_size does not exceed unwinding_size before allocating or storing the values, so a bogus record cannot force a large allocation that is then discarded.
mapped_size is likewise taken from the record and was narrowed into an int for the mmap2 len computation in jit_repipe_code_load() and jit_repipe_code_move(); values above INT_MAX would turn negative, producing a wrong mmap2 length. Use uint64_t for usize so the value cannot truncate.
--- tools/perf/util/jitdump.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
tools/perf/util/jitdump.c +16 -3
@@ -461,7 +461,8 @@ static int jit_repipe_code_load(struct jit_buf_desc *jd, union jr_entry *jr)u16 idr_size;const char *sym;uint64_t count; -int ret, csize, usize; +int ret, csize; +uint64_t usize;pid_t nspid, pid, tid;struct {u32 pid, tid;
@@ -542,7 +543,7 @@ static int jit_repipe_code_load(struct jit_buf_desc *jd, union jr_entry *jr) event->mmap2.pgoff =GEN_ELF_TEXT_OFFSET ; event->mmap2.start = addr; - event->mmap2.len = usize ?ALIGN_8 (csize) + usize : csize; + event->mmap2.len = usize ?ALIGN_8 ((uint64_t )csize) + usize : (uint64_t )csize; event->mmap2.pid = pid; event->mmap2.tid = tid; event->mmap2.ino = st.st_ino;
@@ -595,7 +596,7 @@ static int jit_repipe_code_move(struct jit_buf_desc *jd, union jr_entry *jr)char *filename;size_t size;struct stat st; -int usize; +uint64_t usize;u16 idr_size;int ret;pid_t nspid, pid, tid;
@@ -742,6 +743,18 @@ jit_repipe_unwinding_info(struct jit_buf_desc *jd, union jr_entry *jr)return -1 ; unwinding_data_size = jr->prefix.total_size -sizeof (jr->unwinding); + +/* +* Validate sizes before allocating — jit_add_eh_frame_info() +* computes unwinding_size - eh_frame_hdr_size and uses the +* result as a buffer length for libelf. +*/ +if (jr->unwinding.unwinding_size > unwinding_data_size || + jr->unwinding.eh_frame_hdr_size > jr->unwinding.unwinding_size) { +pr_warning ("jitdump: invalid unwinding sizes in unwinding_info record\n" ); +return -1 ; + } + unwinding_data =malloc (unwinding_data_size);if (!unwinding_data)return -1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2014/3318 remoteproc: qcom_q6v5_adsp: Fix double jiffies conversion in adsp_start()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anup Vishwakarma <[email protected]>
[ Upstream commit f559ef6316971fe39dc5f5edd6a483429ba03768 ]
adsp_start() computes 5 * HZ, an already-converted jiffies count, and passes it into msecs_to_jiffies(), which expects milliseconds -- reinterpreting the value and shrinking the intended timeout. Every other caller (q6v5_start() in qcom_q6v5_mss.c, qcom_pas_start() in qcom_q6v5_pas.c) passes msecs_to_jiffies(5000) directly, matching qcom_q6v5_wait_for_start()'s kerneldoc, which documents @timeout as already being in jiffies.
On CONFIG_HZ=250 this shrinks the intended 5 second timeout to ~1.25 seconds, causing a DSP that legitimately takes 2-3 seconds to signal ready to be spuriously torn down as a boot failure.
Fix by passing msecs_to_jiffies(5000) directly, matching every other caller.
--- drivers/remoteproc/qcom_q6v5_adsp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/qcom_q6v5_adsp.c +1 -1
@@ -438,7 +438,7 @@ static int adsp_start(struct rproc *rproc) goto disable_adsp_clks; } - ret =qcom_q6v5_wait_for_start (&adsp->q6v5,msecs_to_jiffies (5 *HZ )); + ret =qcom_q6v5_wait_for_start (&adsp->q6v5,msecs_to_jiffies (5000 ));if (ret == -ETIMEDOUT ) {dev_err (adsp->dev,"start timed out\n" ); goto disable_adsp_clks;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2015/3318 arm64: dts: qcom: sdm845-sony-xperia-tama: Fix Bluetooth UART pinctrl
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shujath Mohd <[email protected]>
[ Upstream commit cd0f33393882e2554d46e8e068ab95d00593f385 ]
Use the 4-pin UART6 pinctrl configuration for the WCN3990 Bluetooth controller on Sony Xperia Tama devices.
This enables the UART hardware flow control required for reliable Bluetooth communication at higher baud rates.
--- arch/arm64/boot/dts/qcom/sdm845-sony-xperia-tama.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/qcom/sdm845-sony-xperia-tama.dtsi +2 -0
@@ -667,6 +667,8 @@ int-pins { }; &uart6 { + pinctrl-0 = <&qup_uart6_4pin>; + status = "okay"; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2016/3318 remoteproc: xlnx: Initialize mailbox work before requesting channels
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 5ca7dea7cb2e47f42c15ac7206c5e0cba23d292d ]
zynqmp_r5_setup_mbox() installs zynqmp_r5_mb_rx_cb() as the mailbox RX callback before requesting the mailbox channels, but initializes ipi->mbox_work only after both channels have been requested. Once the RX channel is active, a notification delivered before the late INIT_WORK() would make the callback queue an uninitialized work item.
Initialize the work item before requesting channels. Also drain the work before freeing the mailbox state, after the channels have been released so no new callbacks can queue it. Use the same drain before freeing ipi from the channel request error paths, since the callback is already published there as well.
This issue was found by our static analysis tool and then confirmed by manual review of the mailbox setup sequence. The callback is published before the channel requests complete, so the work item should be ready before the mailbox provider can invoke it.
A QEMU PoC modeled a mailbox notification delivered after the RX callback became reachable but before the delayed INIT_WORK(). DEBUG_OBJECTS reported queueing an uninitialized work item from the zynqmp_r5_setup_mbox() path.
This is sent as an RFC because the practical trigger depends on the ZynqMP IPI mailbox provider and firmware delivery timing. If the provider cannot invoke the RX callback until after setup returns, this is a defensive lifecycle cleanup rather than a reachable race on current systems.
--- drivers/remoteproc/xlnx_r5_remoteproc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/remoteproc/xlnx_r5_remoteproc.c +6 -2
@@ -218,6 +218,8 @@ static struct mbox_info *zynqmp_r5_setup_mbox(struct device *cdev)if (!ipi)return NULL ; +INIT_WORK (&ipi->mbox_work, handle_event_notified); + mbox_cl = &ipi->mbox_cl; mbox_cl->rx_callback = zynqmp_r5_mb_rx_cb; mbox_cl->tx_block = false;
@@ -229,6 +231,7 @@ static struct mbox_info *zynqmp_r5_setup_mbox(struct device *cdev) ipi->tx_chan =mbox_request_channel_byname (mbox_cl,"tx" );if (IS_ERR (ipi->tx_chan)) { ipi->tx_chan =NULL ; +cancel_work_sync (&ipi->mbox_work);kfree (ipi);dev_warn (cdev,"mbox tx channel request failed\n" );return NULL ;
@@ -239,13 +242,12 @@ static struct mbox_info *zynqmp_r5_setup_mbox(struct device *cdev)mbox_free_channel (ipi->tx_chan); ipi->rx_chan =NULL ; ipi->tx_chan =NULL ; +cancel_work_sync (&ipi->mbox_work);kfree (ipi);dev_warn (cdev,"mbox rx channel request failed\n" );return NULL ; } -INIT_WORK (&ipi->mbox_work, handle_event_notified); -return ipi; }
@@ -264,6 +266,8 @@ static void zynqmp_r5_free_mbox(struct mbox_info *ipi) ipi->rx_chan =NULL ; } +cancel_work_sync (&ipi->mbox_work); +kfree (ipi); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2017/3318 lsm: dont call security_backing_file_free() multiple times
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cai Xinchen <[email protected]>
[ Upstream commit 3a84fc1a21577dbc8da7e4b6a49c9d8b07c07000 ]
I found the following path:
alloc_empty_backing-file
init_file(&ff->file, xxx)
-> file_ref_init(&f->f_ref, 1); // only 1
error = init_backing_file
-> security_backing_file_alloc
-> rc = call_int_hook(backing_file_alloc, ...)
if (unlikely(rc))
security_backing_file_free(backing_file); // first call
if (unlikely(error)) {
fput(&ff->file);
-> if (unlikely(file_ref_put(&file->f_ref))) // zero
__fput_deferred(file);
-> ____fput -> __fput -> file_free(file);
-> backing_file_free(backing_file(f));
-> security_backing_file_free(&ff->file); // second callCurrently, only SELinux has the lsm backing_file_alloc hook, and it always return 0. When security_backing_file_free is called for the first time, the blobs pointer is set to NULL. Therefore, double free will not occur in the code.
--- security/security.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
security/security.c +1 -2
@@ -2709,9 +2709,8 @@ void security_backing_file_free(struct file *backing_file) {void *blob =backing_file_security (backing_file); -call_void_hook (backing_file_free, backing_file); -if (blob) { +call_void_hook (backing_file_free, backing_file);backing_file_set_security (backing_file,NULL );kmem_cache_free (lsm_backing_file_cache, blob); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2018/3318 ASoC: wcd-mbhc-v2: Fix incorrect properties names and typos
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Heidelberg <[email protected]>
[ Upstream commit 17bca5d55446c1e21944d47354ee2f0b80db36d6 ]
Improves debugging experience.
--- sound/soc/codecs/wcd-mbhc-v2.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/codecs/wcd-mbhc-v2.c +4 -4
@@ -802,7 +802,7 @@ static int wcd_measure_adc_continuous(struct wcd_mbhc *mbhc)u8 adc_en;/* Pre-requisites for ADC continuous measurement */ -/* Read legacy electircal detection and disable */ +/* Read legacy electrical detection and disable */ wcd_mbhc_write_field (mbhc,WCD_MBHC_ELECT_SCHMT_ISRC ,0x00 );/* Set ADC to continuous measurement */ wcd_mbhc_write_field (mbhc,WCD_MBHC_ADC_MODE ,1 );
@@ -903,7 +903,7 @@ static int wcd_check_cross_conn(struct wcd_mbhc *mbhc)if (wcd_mbhc_read_field (mbhc,WCD_MBHC_HPH_PA_EN ))return -EINVAL ; -/* Read legacy electircal detection and disable */ +/* Read legacy electrical detection and disable */ elect_ctl =wcd_mbhc_read_field (mbhc,WCD_MBHC_ELECT_SCHMT_ISRC );wcd_mbhc_write_field (mbhc,WCD_MBHC_ELECT_SCHMT_ISRC ,0 );
@@ -1409,14 +1409,14 @@ int wcd_dt_parse_mbhc_data(struct device *dev, struct wcd_mbhc_config *cfg) ret =of_property_read_u32 (np,"qcom,mbhc-headset-vthreshold-microvolt" , µvolt);if (ret) -dev_dbg (dev,"missing qcom,mbhc-hs-mic-max-vthreshold--microvolt in dt node\n" ); +dev_dbg (dev,"missing qcom,mbhc-headset-vthreshold-microvolt in dt node\n" );else cfg->hs_thr = microvolt/1000 ; ret =of_property_read_u32 (np,"qcom,mbhc-headphone-vthreshold-microvolt" , µvolt);if (ret) -dev_dbg (dev,"missing qcom,mbhc-hs-mic-min-vthreshold-microvolt entry\n" ); +dev_dbg (dev,"missing qcom,mbhc-headphone-vthreshold-microvolt entry\n" );else cfg->hph_thr = microvolt/1000 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2019/3318 pwm: renesas: Drop usage of pwm_[gs]et_chip_data()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit ec63391a0d402cafa5f4dfd11e05cd325ae7e2f5 ]
Instead of distributing the driver's bookkeeping over 5 (i.e. TPU_CHANNEL_MAX + 1) separately allocated memory chunks, put all together in struct tpu_device. This reduces the number of memory allocations and so fragmentation and maybe even the number of cache misses. Also &tpu->tpd[pwm->hwpwm] is cheaper to evaluate than pwm_get_chip_data(pwm) as the former is just an addition in machine code while the latter involves a function call.
Stable-dep-of: 62cff15fbf2b ("pwm: renesas-tpu: Fix runtime PM reference leak")
--- drivers/pwm/pwm-renesas-tpu.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/pwm/pwm-renesas-tpu.c +11 -11
@@ -85,6 +85,7 @@ struct tpu_device {void __iomem *base;struct clk *clk; +struct tpu_pwm_device tpd[TPU_CHANNEL_MAX ]; };#define to_tpu_device (c) container_of(c, struct tpu_device, chip)
@@ -215,9 +216,7 @@ static int tpu_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)if (pwm->hwpwm >=TPU_CHANNEL_MAX )return -EINVAL ; - tpd =kzalloc (sizeof (*tpd),GFP_KERNEL ); -if (tpd ==NULL ) -return -ENOMEM ; + tpd = &tpu->tpd[pwm->hwpwm]; tpd->tpu = tpu; tpd->channel = pwm->hwpwm;
@@ -228,24 +227,22 @@ static int tpu_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) tpd->timer_on = false; -pwm_set_chip_data (pwm, tpd); -return 0 ; }static void tpu_pwm_free (struct pwm_chip *chip,struct pwm_device *pwm) { -struct tpu_pwm_device *tpd =pwm_get_chip_data (pwm); +struct tpu_device *tpu =to_tpu_device (chip); +struct tpu_pwm_device *tpd = &tpu->tpd[pwm->hwpwm];tpu_pwm_timer_stop (tpd); -kfree (tpd); }static int tpu_pwm_config (struct pwm_chip *chip,struct pwm_device *pwm,u64 duty_ns,u64 period_ns,bool enabled) { -struct tpu_pwm_device *tpd =pwm_get_chip_data (pwm);struct tpu_device *tpu =to_tpu_device (chip); +struct tpu_pwm_device *tpd = &tpu->tpd[pwm->hwpwm];unsigned int prescaler;bool duty_only = false;u32 clk_rate;
@@ -353,7 +350,8 @@ static int tpu_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,static int tpu_pwm_set_polarity (struct pwm_chip *chip,struct pwm_device *pwm,enum pwm_polarity polarity) { -struct tpu_pwm_device *tpd =pwm_get_chip_data (pwm); +struct tpu_device *tpu =to_tpu_device (chip); +struct tpu_pwm_device *tpd = &tpu->tpd[pwm->hwpwm]; tpd->polarity = polarity;
@@ -362,7 +360,8 @@ static int tpu_pwm_set_polarity(struct pwm_chip *chip, struct pwm_device *pwm,static int tpu_pwm_enable (struct pwm_chip *chip,struct pwm_device *pwm) { -struct tpu_pwm_device *tpd =pwm_get_chip_data (pwm); +struct tpu_device *tpu =to_tpu_device (chip); +struct tpu_pwm_device *tpd = &tpu->tpd[pwm->hwpwm];int ret; ret =tpu_pwm_timer_start (tpd);
@@ -384,7 +383,8 @@ static int tpu_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)static void tpu_pwm_disable (struct pwm_chip *chip,struct pwm_device *pwm) { -struct tpu_pwm_device *tpd =pwm_get_chip_data (pwm); +struct tpu_device *tpu =to_tpu_device (chip); +struct tpu_pwm_device *tpd = &tpu->tpd[pwm->hwpwm];/* The timer must be running to modify the pin output configuration. */ tpu_pwm_timer_start (tpd);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2020/3318 pwm: renesas-tpu: Fix runtime PM reference leak
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 62cff15fbf2b12ebbb0b01ca720030c2bc12aed1 ]
tpu_pwm_timer_start() used pm_runtime_get_sync() without checking its return value before touching the TPU clock. A failed runtime resume was therefore ignored, and the callback continued into register access.
Use pm_runtime_resume_and_get() and propagate a failed resume. Keep the matching put when clock preparation fails after a successful resume.
tpu_pwm_disable() also needs to propagate a failed start so that the PWM apply callback does not access registers while runtime PM is inactive.
This issue was found by a static analysis checker and confirmed by manual source review.
--- drivers/pwm/pwm-renesas-tpu.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
drivers/pwm/pwm-renesas-tpu.c +18 -5
@@ -148,10 +148,14 @@ static int tpu_pwm_timer_start(struct tpu_pwm_device *tpd)if (!tpd->timer_on) {/* Wake up device and enable clock. */ -pm_runtime_get_sync (&tpd->tpu->pdev->dev); + ret =pm_runtime_resume_and_get (&tpd->tpu->pdev->dev); +if (ret <0 ) +return ret; + ret =clk_prepare_enable (tpd->tpu->clk);if (ret) {dev_err (&tpd->tpu->pdev->dev,"cannot enable clock\n" ); +pm_runtime_put (&tpd->tpu->pdev->dev);return ret; } tpd->timer_on = true;
@@ -381,15 +385,21 @@ static int tpu_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)return 0 ; } -static void tpu_pwm_disable (struct pwm_chip *chip,struct pwm_device *pwm) +static int tpu_pwm_disable (struct pwm_chip *chip,struct pwm_device *pwm) {struct tpu_device *tpu =to_tpu_device (chip);struct tpu_pwm_device *tpd = &tpu->tpd[pwm->hwpwm]; +int ret;/* The timer must be running to modify the pin output configuration. */ -tpu_pwm_timer_start (tpd); + ret =tpu_pwm_timer_start (tpd); +if (ret <0 ) +return ret; +tpu_pwm_set_pin (tpd,TPU_PIN_INACTIVE );tpu_pwm_timer_stop (tpd); + +return 0 ; } static int tpu_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
@@ -400,7 +410,10 @@ static int tpu_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,if (state->polarity != pwm->state.polarity) {if (enabled) { -tpu_pwm_disable (chip, pwm); + err =tpu_pwm_disable (chip, pwm); +if (err) +return err; + enabled = false; }
@@ -411,7 +424,7 @@ static int tpu_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,if (!state->enabled) {if (enabled) -tpu_pwm_disable (chip, pwm); +return tpu_pwm_disable (chip, pwm);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2021/3318 spi: omap2-mcspi: Remove unbalanced pm_runtime_put_sync() calls
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Gu <[email protected]>
[ Upstream commit 5f01cb141169fe422c42279f7d502479b1ff9fd2 ]
pm_runtime_put_sync() is called in the probe error path and in remove when nothing holds a runtime PM reference anymore, so it underflows the usage count.
--- drivers/spi/spi-omap2-mcspi.c | 2 -- 1 file changed, 2 deletions(-)
drivers/spi/spi-omap2-mcspi.c +0 -2
@@ -1549,7 +1549,6 @@ static int omap2_mcspi_probe(struct platform_device *pdev) disable_pm:pm_runtime_dont_use_autosuspend (&pdev->dev); -pm_runtime_put_sync (&pdev->dev);pm_runtime_disable (&pdev->dev); free_ctlr:omap2_mcspi_release_dma (ctlr);
@@ -1569,7 +1568,6 @@ static void omap2_mcspi_remove(struct platform_device *pdev)omap2_mcspi_release_dma (ctlr);pm_runtime_dont_use_autosuspend (mcspi->dev); -pm_runtime_put_sync (mcspi->dev);pm_runtime_disable (&pdev->dev);spi_controller_put (ctlr);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2022/3318 soc: qcom: apr: clean up failed service registrations
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongyan Xu <[email protected]>
[ Upstream commit 7dc14f37ca4ee35040c67c4b0180dd7b32079caf ]
apr_add_device() publishes a service in svcs_idr before parsing the optional protection domain and registering the device. If device registration fails, put_device() frees the apr_device while its service remains in the IDR. A received packet can then dereference that stale entry. The property error path also leaves the service and allocation behind.
Split device_register() into device_initialize() and device_add() so every pre-registration error can safely drop the device reference. Remove the service from the IDR on all failures after publication, then drain the RX workqueue before dropping the device reference. This prevents an in-flight lookup from outliving the device.
--- drivers/soc/qcom/apr.c | 44 +++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 16 deletions(-)
drivers/soc/qcom/apr.c +28 -16
@@ -434,31 +434,35 @@ static int apr_add_device(struct device *dev, struct device_node *np,if (np)snprintf (adev->name,APR_NAME_SIZE ,"%pOFn" , np); + adev->dev.bus = &aprbus; + adev->dev.parent = dev; + adev->dev.of_node = np; + adev->dev.release = apr_dev_release; + adev->dev.driver =NULL ; +device_initialize (&adev->dev); +switch (apr->type) {case PR_TYPE_APR : -dev_set_name (&adev->dev,"aprsvc:%s:%x:%x" , adev->name, - domain_id, svc_id); + ret =dev_set_name (&adev->dev,"aprsvc:%s:%x:%x" , adev->name, + domain_id, svc_id);break ;case PR_TYPE_GPR : -dev_set_name (&adev->dev,"gprsvc:%s:%x:%x" , adev->name, - domain_id, svc_id); + ret =dev_set_name (&adev->dev,"gprsvc:%s:%x:%x" , adev->name, + domain_id, svc_id);break ;default : + ret = -EINVAL ;break ; } - - adev->dev.bus = &aprbus; - adev->dev.parent = dev; - adev->dev.of_node = np; - adev->dev.release = apr_dev_release; - adev->dev.driver =NULL ; +if (ret) + goto out_put_device;spin_lock (&apr->svcs_lock); ret =idr_alloc (&apr->svcs_idr, svc, svc_id, svc_id +1 ,GFP_ATOMIC );spin_unlock (&apr->svcs_lock);if (ret <0 ) {dev_err (dev,"idr_alloc failed: %d\n" , ret); - goto out; + goto out_put_device; }/* Protection domain is optional, it does not exist on older platforms */
@@ -466,18 +470,26 @@ static int apr_add_device(struct device *dev, struct device_node *np, 1, &adev->service_path);if (ret <0 && ret != -EINVAL ) {dev_err (dev,"Failed to read second value of qcom,protection-domain\n" ); - goto out; + goto out_remove_idr; }dev_info (dev,"Adding APR/GPR dev: %s\n" ,dev_name (&adev->dev)); - ret =device_register (&adev->dev); + ret =device_add (&adev->dev);if (ret) { -dev_err (dev,"device_register failed: %d\n" , ret); -put_device (&adev->dev); +dev_err (dev,"device_add failed: %d\n" , ret); + goto out_remove_idr; } -out: +return 0 ; + +out_remove_idr: +spin_lock (&apr->svcs_lock); +idr_remove (&apr->svcs_idr, svc_id); +spin_unlock (&apr->svcs_lock); +flush_workqueue (apr->rxwq); +out_put_device: +put_device (&adev->dev);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2023/3318 platform/chrome: cros_ec_proto: Fix deferred response
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rob Barnes <[email protected]>
[ Upstream commit c55749415623a58eba3eb527da023d29b43fbf5d ]
When cros_ec_wait_until_complete() succeeds after an EC_RES_IN_PROGRESS status, it previously returned the 4-byte transfer size of EC_CMD_GET_COMMS_STATUS. For 0-byte payload commands (such as EC_CMD_FLASH_ERASE), userspace received 4 bytes instead of 0, causing response size validation errors. For commands expecting non-zero response payloads, the kernel exited without issuing EC_CMD_RESEND_RESPONSE, leaving response buffers uninitialized.
Refactor cros_ec_wait_until_complete() to pass orig_msg, issue EC_CMD_RESEND_RESPONSE into orig_msg->data when insize > 0, and return 0 for 0-byte response commands.
--- drivers/platform/chrome/cros_ec_proto.c | 32 +++- drivers/platform/chrome/cros_ec_proto_test.c | 158 ++++++++++++++++++- 2 files changed, 183 insertions(+), 7 deletions(-)
drivers/platform/chrome/cros_ec_proto.c +28 -4
@@ -134,7 +134,8 @@ static int cros_ec_xfer_command(struct cros_ec_device *ec_dev, struct cros_ec_coreturn ret; } -static int cros_ec_wait_until_complete (struct cros_ec_device *ec_dev,uint32_t *result) +static int cros_ec_wait_until_complete (struct cros_ec_device *ec_dev, +struct cros_ec_command *orig_msg) {struct {struct cros_ec_command msg;
@@ -159,7 +160,7 @@ static int cros_ec_wait_until_complete(struct cros_ec_device *ec_dev, uint32_t *if (ret <0 )return ret; - *result = msg->result; + orig_msg->result = msg->result;if (msg->result !=EC_RES_SUCCESS )return ret;
@@ -168,8 +169,31 @@ static int cros_ec_wait_until_complete(struct cros_ec_device *ec_dev, uint32_t *break ; } -if (!(status->flags &EC_COMMS_STATUS_PROCESSING )) +if (!(status->flags &EC_COMMS_STATUS_PROCESSING )) { +u32 orig_cmd, orig_outsize, orig_version; + +/* If no response payload is expected, return 0. */ +if (orig_msg->insize ==0 ) +return 0 ; + +/* +* Request the response using EC_CMD_RESEND_RESPONSE. +* Restore the original message fields so it appears +* to be a direct response to the original command. +*/ + orig_cmd = orig_msg->command; + orig_outsize = orig_msg->outsize; + orig_version = orig_msg->version; + + orig_msg->command =EC_CMD_RESEND_RESPONSE ; + orig_msg->outsize =0 ; + orig_msg->version =0 ; + ret =cros_ec_xfer_command (ec_dev, orig_msg); + orig_msg->command = orig_cmd; + orig_msg->outsize = orig_outsize; + orig_msg->version = orig_version;return ret; + } }if (i >=EC_COMMAND_RETRIES )
@@ -183,7 +207,7 @@ static int cros_ec_send_command(struct cros_ec_device *ec_dev, struct cros_ec_coint ret =cros_ec_xfer_command (ec_dev, msg);if (msg->result ==EC_RES_IN_PROGRESS ) - ret =cros_ec_wait_until_complete (ec_dev, &msg->result); + ret =cros_ec_wait_until_complete (ec_dev, msg);return ret; }
drivers/platform/chrome/cros_ec_proto_test.c +155 -3
182 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2024/3318 staging: rtl8723bs: change remaining printk to proper api
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rodrigo Gobbi <[email protected]>
[ Upstream commit e139445ccbe4d902fce1dce517cd3b63f5b68eb8 ]
As part of TODO file for future work, use dyn debug api for remaining printk statements.
Stable-dep-of: baa84b1bb164 ("staging: rtl8723bs: disable SDIO function on block size failure")
--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 6 +++--- drivers/staging/rtl8723bs/hal/hal_com.c | 7 +++---- drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 12 ++++++++---- drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +3 -3
@@ -1886,10 +1886,10 @@ unsigned int OnAction_sa_query(struct adapter *padapter, union recv_frame *precvif (0 ) {int pp; -printk ("pattrib->pktlen = %d =>" , pattrib->pkt_len); +netdev_dbg (padapter->pnetdev,"pattrib->pktlen = %d =>" , pattrib->pkt_len);for (pp =0 ; pp < pattrib->pkt_len; pp++) -printk (" %02x " , pframe[pp]); -printk ("\n" ); +pr_cont (" %02x " , pframe[pp]); +pr_cont ("\n" ); }return _SUCCESS;
drivers/staging/rtl8723bs/hal/hal_com.c +3 -4
@@ -911,10 +911,9 @@ void rtw_dump_raw_rssi_info(struct adapter *padapter)for (rf_path =0 ; rf_path < pHalData->NumTotalRFPath; rf_path++) {if (!isCCKrate) { -printk (", rx_ofdm_pwr:%d(dBm), rx_ofdm_snr:%d(dB)\n" , - psample_pkt_rssi->ofdm_pwr[rf_path], psample_pkt_rssi->ofdm_snr[rf_path]); - }else { -printk ("\n" ); +netdev_dbg (padapter->pnetdev,", rx_ofdm_pwr:%d(dBm), rx_ofdm_snr:%d(dB)\n" , + psample_pkt_rssi->ofdm_pwr[rf_path], + psample_pkt_rssi->ofdm_snr[rf_path]); } } }
drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +8 -4
@@ -63,7 +63,8 @@ static int _BlockWrite(struct adapter *padapter, void *buffer, u32 buffSize)for (i =0 ; i < blockCount_p1; i++) { ret =rtw_write32 (padapter, (FW_8723B_START_ADDRESS + i * blockSize_p1), *((u32 *)(bufferPtr + i * blockSize_p1)));if (ret == _FAIL) { -printk ("====>%s %d i:%d\n" , __func__, __LINE__, i); +netdev_dbg (padapter->pnetdev,"write failed at %s %d, block:%d\n" , + __func__, __LINE__, i); goto exit; } }
@@ -86,7 +87,8 @@ static int _BlockWrite(struct adapter *padapter, void *buffer, u32 buffSize) ret =rtw_write8 (padapter, (FW_8723B_START_ADDRESS + offset + i), *(bufferPtr + offset + i));if (ret == _FAIL) { -printk ("====>%s %d i:%d\n" , __func__, __LINE__, i); +netdev_dbg (padapter->pnetdev,"write failed at %s %d, block:%d\n" , + __func__, __LINE__, i); goto exit; } }
@@ -128,7 +130,8 @@ static int _WriteFW(struct adapter *padapter, void *buffer, u32 size) ret =_PageWrite (padapter, page, bufferPtr+offset,MAX_DLFW_PAGE_SIZE );if (ret == _FAIL) { -printk ("====>%s %d\n" , __func__, __LINE__); +netdev_dbg (padapter->pnetdev,"page write failed at %s %d\n" , + __func__, __LINE__); goto exit; } }
@@ -139,7 +142,8 @@ static int _WriteFW(struct adapter *padapter, void *buffer, u32 size) ret =_PageWrite (padapter, page, bufferPtr+offset, remainSize);if (ret == _FAIL) { -printk ("====>%s %d\n" , __func__, __LINE__); +netdev_dbg (padapter->pnetdev,"remaining page write failed at %s %d\n" , + __func__, __LINE__); goto exit; } }
drivers/staging/rtl8723bs/os_dep/sdio_intf.c +1 -1
@@ -73,7 +73,7 @@ static int sdio_alloc_irq(struct dvobj_priv *dvobj) err =sdio_claim_irq (func, &sd_sync_int_hdl);if (err) { dvobj->drv_dbg.dbg_sdio_alloc_irq_error_cnt++; -printk (KERN_CRIT "%s: sdio_claim_irq FAIL(%d)!\n" , __func__, err); +netdev_crit (dvobj->if1->pnetdev,"%s: sdio_claim_irq FAIL(%d)!\n" , __func__, err); }else { dvobj->drv_dbg.dbg_sdio_alloc_irq_cnt++; dvobj->irq_alloc =1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2025/3318 staging: rtl8723bs: remove return from void function
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Straube <[email protected]>
[ Upstream commit 9279204d37cce549f40cdc677b86405e8628212c ]
Remove exit label and return statement from a void function. After the exit label no cleanup is done, so it is safe to remove it and return early in the only place where the label is used. This simplifies the code and clears a checkpatch warning.
WARNING: void function return statements are not generally useful
Stable-dep-of: baa84b1bb164 ("staging: rtl8723bs: disable SDIO function on block size failure")
--- drivers/staging/rtl8723bs/os_dep/os_intfs.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/staging/rtl8723bs/os_dep/os_intfs.c +1 -5
@@ -1145,7 +1145,7 @@ void rtw_suspend_common(struct adapter *padapter)if ((!padapter->bup) || (padapter->bDriverStopped) || (padapter->bSurpriseRemoved)) { pdbgpriv->dbg_suspend_error_cnt++; - goto exit; +return ; }rtw_ps_deny (padapter,PS_DENY_SUSPEND );
@@ -1167,10 +1167,6 @@ void rtw_suspend_common(struct adapter *padapter)netdev_dbg (padapter->pnetdev,"rtw suspend success in %d ms\n" ,jiffies_to_msecs (jiffies - start_time)); - -exit: - -return ; }static int rtw_resume_process_normal (struct adapter *padapter)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2026/3318 staging: rtl8723bs: remove wrapper rtw_init_recv_timer
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Straube <[email protected]>
[ Upstream commit 0149f27d1a248f013fe36d29bc391c303e853ee0 ]
The function rtw_init_recv_timer in os_dep/recv_linux.c is jsut a wrapper around timer_setup. Use timer_setup directly and remove the wrapper to reduce code in the os_dep directory.
Stable-dep-of: baa84b1bb164 ("staging: rtl8723bs: disable SDIO function on block size failure")
--- drivers/staging/rtl8723bs/core/rtw_sta_mgt.c | 4 +++- drivers/staging/rtl8723bs/include/recv_osdep.h | 3 --- drivers/staging/rtl8723bs/os_dep/recv_linux.c | 7 ------- 3 files changed, 3 insertions(+), 11 deletions(-)
drivers/staging/rtl8723bs/core/rtw_sta_mgt.c +3 -1
@@ -249,7 +249,9 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)INIT_LIST_HEAD (&preorder_ctrl->pending_recvframe_queue.queue);spin_lock_init (&preorder_ctrl->pending_recvframe_queue.lock); -rtw_init_recv_timer (preorder_ctrl); +/* init recv timer */ +timer_setup (&preorder_ctrl->reordering_ctrl_timer, + rtw_reordering_ctrl_timeout_handler,0 ); }/* init for DM */
drivers/staging/rtl8723bs/include/recv_osdep.h +0 -3
@@ -34,7 +34,4 @@ void rtw_os_recvbuf_resource_free(struct adapter *padapter, struct recv_buf *prestruct sk_buff *rtw_os_alloc_msdu_pkt (union recv_frame *prframe,u16 nSubframe_Length,u8 *pdata);void rtw_os_recv_indicate_pkt (struct adapter *padapter,struct sk_buff *pkt,struct rx_pkt_attrib *pattrib); -void rtw_init_recv_timer (struct recv_reorder_ctrl *preorder_ctrl); - -#endif /* */
drivers/staging/rtl8723bs/os_dep/recv_linux.c +0 -7
@@ -220,10 +220,3 @@ int rtw_recv_indicatepkt(struct adapter *padapter, union recv_frame *precv_framereturn _FAIL; } - -void rtw_init_recv_timer (struct recv_reorder_ctrl *preorder_ctrl) -{ -timer_setup (&preorder_ctrl->reordering_ctrl_timer, - rtw_reordering_ctrl_timeout_handler,0 ); - -}
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2027/3318 staging: rtl8723bs: move rtw_recv_indicatepkt to rtw_recv.c
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Straube <[email protected]>
[ Upstream commit f97151eb17dcdc8d7a27e05f2ec8c55bbb16c7a9 ]
Move the function rtw_recv_indicatepkt from os_dep/recv_linux.c to core/rtw_recv.c to reduce code in the os_dep directory.
Stable-dep-of: baa84b1bb164 ("staging: rtl8723bs: disable SDIO function on block size failure")
--- drivers/staging/rtl8723bs/core/rtw_recv.c | 37 +++++++++++++++++++ .../staging/rtl8723bs/include/recv_osdep.h | 1 - drivers/staging/rtl8723bs/os_dep/recv_linux.c | 37 ------------------- 3 files changed, 37 insertions(+), 38 deletions(-)
drivers/staging/rtl8723bs/core/rtw_recv.c +37 -0
@@ -1741,6 +1741,43 @@ static void recv_indicatepkts_pkt_loss_cnt(struct debug_priv *pdbgpriv, u64 prev } +static int rtw_recv_indicatepkt (struct adapter *padapter,union recv_frame *precv_frame) +{ +struct recv_priv *precvpriv; +struct __queue *pfree_recv_queue; +struct sk_buff *skb; +struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + + precvpriv = &(padapter->recvpriv); + pfree_recv_queue = &(precvpriv->free_recv_queue); + + skb = precv_frame->u.hdr.pkt; +if (!skb) + goto _recv_indicatepkt_drop; + + skb->data = precv_frame->u.hdr.rx_data; + +skb_set_tail_pointer (skb, precv_frame->u.hdr.len); + + skb->len = precv_frame->u.hdr.len; + +rtw_os_recv_indicate_pkt (padapter, skb, pattrib); + +/* pointers to NULL before rtw_free_recvframe() */ + precv_frame->u.hdr.pkt =NULL ; + +rtw_free_recvframe (precv_frame, pfree_recv_queue); + +return _SUCCESS; + +_recv_indicatepkt_drop: + +/* enqueue back to free_recv_queue */ +rtw_free_recvframe (precv_frame, pfree_recv_queue); + +return _FAIL; +} +static int recv_indicatepkts_in_order (struct adapter *padapter,struct recv_reorder_ctrl *preorder_ctrl,int bforced) {struct list_head *phead, *plist;
drivers/staging/rtl8723bs/include/recv_osdep.h +0 -1
@@ -13,7 +13,6 @@ extern void _rtw_free_recv_priv(struct recv_priv *precvpriv);extern s32 rtw_recv_entry (union recv_frame *precv_frame); -extern int rtw_recv_indicatepkt (struct adapter *adapter,union recv_frame *precv_frame);extern void rtw_recv_returnpacket (struct net_device *cnxt,struct sk_buff *preturnedpkt);extern void rtw_handle_tkip_mic_err (struct adapter *padapter,u8 bgroup);
drivers/staging/rtl8723bs/os_dep/recv_linux.c +0 -37
@@ -183,40 +183,3 @@ void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup)memset (&wrqu,0x00 ,sizeof (wrqu)); wrqu.data.length =sizeof (ev); } - -int rtw_recv_indicatepkt (struct adapter *padapter,union recv_frame *precv_frame) -{ -struct recv_priv *precvpriv; -struct __queue *pfree_recv_queue; -struct sk_buff *skb; -struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; - - precvpriv = &(padapter->recvpriv); - pfree_recv_queue = &(precvpriv->free_recv_queue); - - skb = precv_frame->u.hdr.pkt; -if (!skb) - goto _recv_indicatepkt_drop; - - skb->data = precv_frame->u.hdr.rx_data; - -skb_set_tail_pointer (skb, precv_frame->u.hdr.len); - - skb->len = precv_frame->u.hdr.len; - -rtw_os_recv_indicate_pkt (padapter, skb, pattrib); - -/* pointers to NULL before rtw_free_recvframe() */ - precv_frame->u.hdr.pkt =NULL ; - -rtw_free_recvframe (precv_frame, pfree_recv_queue); - -return _SUCCESS; - -_recv_indicatepkt_drop: - -/* enqueue back to free_recv_queue */ -rtw_free_recvframe (precv_frame, pfree_recv_queue); - -return _FAIL; -}
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2028/3318 staging: rtl8723bs: remove unused private debug counters
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ethan Tidmore <[email protected]>
[ Upstream commit 7de30d5d76aa614777a02a9807d29ed65b0704a0 ]
The driver maintains a private struct debug_priv embedded within struct dvobj_priv to track various error counters (e.g., suspend errors, alloc failures, RX drops).
These counters are incremented in various files but the data is never read or exposed to userspace.
Remove the unused debug_priv structure definition, the instance in dvobj_priv, and all associated increment operations across the driver to clean up the code.
This also removes the following helper functions which were used solely to update these counters:
- rtw_reset_rx_info()
- recv_indicatepkts_pkt_loss_cnt()
Stable-dep-of: baa84b1bb164 ("staging: rtl8723bs: disable SDIO function on block size failure")
--- drivers/staging/rtl8723bs/core/rtw_mlme.c | 13 ------ drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 3 -- drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 6 +-- drivers/staging/rtl8723bs/core/rtw_recv.c | 24 +--------- drivers/staging/rtl8723bs/hal/hal_com.c | 13 ------ .../staging/rtl8723bs/hal/rtl8723b_hal_init.c | 4 -- drivers/staging/rtl8723bs/hal/sdio_halinit.c | 8 +--- drivers/staging/rtl8723bs/include/drv_types.h | 41 ----------------- drivers/staging/rtl8723bs/os_dep/os_intfs.c | 15 +------ drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 45 +++++-------------- 10 files changed, 15 insertions(+), 157 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme.c +0 -13
@@ -808,15 +808,6 @@ static void free_scanqueue(struct mlme_priv *pmlmepriv)spin_unlock_bh (&scan_queue->lock); } -static void rtw_reset_rx_info (struct debug_priv *pdbgpriv) -{ - pdbgpriv->dbg_rx_ampdu_drop_count =0 ; - pdbgpriv->dbg_rx_ampdu_forced_indicate_count =0 ; - pdbgpriv->dbg_rx_ampdu_loss_count =0 ; - pdbgpriv->dbg_rx_dup_mgt_frame_drop_count =0 ; - pdbgpriv->dbg_rx_ampdu_window_shift_cnt =0 ; -} -static void find_network (struct adapter *adapter) {struct wlan_network *pwlan =NULL ;
@@ -841,8 +832,6 @@ void rtw_free_assoc_resources(struct adapter *adapter, int lock_scanned_queue) {struct mlme_priv *pmlmepriv = &adapter->mlmepriv;struct wlan_network *tgt_network = &pmlmepriv->cur_network; -struct dvobj_priv *psdpriv = adapter->dvobj; -struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;if (check_fwstate (pmlmepriv,WIFI_STATION_STATE |WIFI_AP_STATE )) {struct sta_info *psta;
@@ -866,8 +855,6 @@ void rtw_free_assoc_resources(struct adapter *adapter, int lock_scanned_queue)if (lock_scanned_queue) adapter->securitypriv.key_mask =0 ; - -rtw_reset_rx_info (pdbgpriv); }/*
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +0 -3
@@ -440,8 +440,6 @@ void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame)struct mlme_priv *pmlmepriv = &padapter->mlmepriv;u8 *pframe = precv_frame->u.hdr.rx_data;struct sta_info *psta =rtw_get_stainfo (&padapter->stapriv,GetAddr2Ptr (pframe)); -struct dvobj_priv *psdpriv = padapter->dvobj; -struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;if (GetFrameType (pframe) !=WIFI_MGT_TYPE )return ;
@@ -465,7 +463,6 @@ void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame)if (GetRetry (pframe)) {if (precv_frame->u.hdr.attrib.seq_num == psta->RxMgmtFrameSeqNum) {/* drop the duplicate management frame */ - pdbgpriv->dbg_rx_dup_mgt_frame_drop_count++;return ; } }
drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +1 -5
@@ -145,8 +145,6 @@ static bool rtw_pwr_unassociated_idle(struct adapter *adapter)void rtw_ps_processor (struct adapter *padapter) {struct pwrctrl_priv *pwrpriv =adapter_to_pwrctl (padapter); -struct dvobj_priv *psdpriv = padapter->dvobj; -struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;u32 ps_deny =0 ;mutex_lock (&adapter_to_pwrctl (padapter)->lock);
@@ -155,10 +153,8 @@ void rtw_ps_processor(struct adapter *padapter)if (ps_deny !=0 ) goto exit; -if (pwrpriv->bInSuspend) {/* system suspend or autosuspend */ - pdbgpriv->dbg_ps_insuspend_cnt++; +if (pwrpriv->bInSuspend)/* system suspend or autosuspend */ return ; - } pwrpriv->ps_processing = true;
drivers/staging/rtl8723bs/core/rtw_recv.c +1 -23
@@ -1653,9 +1653,6 @@ static int amsdu_to_msdu(struct adapter *padapter, union recv_frame *prframe)static int check_indicate_seq (struct recv_reorder_ctrl *preorder_ctrl,u16 seq_num) { -struct adapter *padapter = preorder_ctrl->padapter; -struct dvobj_priv *psdpriv = padapter->dvobj; -struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;u8 wsize = preorder_ctrl->wsize_b;u16 wend = (preorder_ctrl->indicate_seq + wsize -1 ) &0xFFF ;/* 4096; */
@@ -1681,7 +1678,6 @@ static int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, u16 seq_n preorder_ctrl->indicate_seq = seq_num +1 - wsize; else preorder_ctrl->indicate_seq = 0xFFF - (wsize - (seq_num + 1)) + 1; - pdbgpriv->dbg_rx_ampdu_window_shift_cnt++; }return true;
@@ -1732,15 +1728,6 @@ static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, un } -static void recv_indicatepkts_pkt_loss_cnt (struct debug_priv *pdbgpriv,u64 prev_seq,u64 current_seq) -{ -if (current_seq < prev_seq) - pdbgpriv->dbg_rx_ampdu_loss_count += (4096 + current_seq - prev_seq); -else - pdbgpriv->dbg_rx_ampdu_loss_count += (current_seq - prev_seq); - -} -static int rtw_recv_indicatepkt (struct adapter *padapter,union recv_frame *precv_frame) {struct recv_priv *precvpriv;
@@ -1787,8 +1774,6 @@ static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reorint bPktInBuf = false;struct recv_priv *precvpriv = &padapter->recvpriv;struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; -struct dvobj_priv *psdpriv = padapter->dvobj; -struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;/* spin_lock_irqsave(&ppending_recvframe_queue->lock, irql); */ /* spin_lock(&ppending_recvframe_queue->lock); */
@@ -1798,7 +1783,6 @@ static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reor/* Handling some condition for forced indicate case. */ if (bforced == true) { - pdbgpriv->dbg_rx_ampdu_forced_indicate_count++;if (list_empty (phead)) {/* spin_unlock_irqrestore(&ppending_recvframe_queue->lock, irql); */ /* spin_unlock(&ppending_recvframe_queue->lock); */
@@ -1808,7 +1792,6 @@ static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reor prframe = (union recv_frame *)plist; pattrib = &prframe->u.hdr.attrib; -recv_indicatepkts_pkt_loss_cnt (pdbgpriv, preorder_ctrl->indicate_seq, pattrib->seq_num); preorder_ctrl->indicate_seq = pattrib->seq_num; }
@@ -1869,8 +1852,6 @@ static int recv_indicatepkt_reorder(struct adapter *padapter, union recv_frame *struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib;struct recv_reorder_ctrl *preorder_ctrl = prframe->u.hdr.preorder_ctrl;struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; -struct dvobj_priv *psdpriv = padapter->dvobj; -struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;if (!pattrib->amsdu) {/* s1. */
@@ -1916,11 +1897,8 @@ static int recv_indicatepkt_reorder(struct adapter *padapter, union recv_frame *spin_lock_bh (&ppending_recvframe_queue->lock);/* s2. check if winstart_b(indicate_seq) needs to been updated */ -if (!check_indicate_seq (preorder_ctrl, pattrib->seq_num)) { - pdbgpriv->dbg_rx_ampdu_drop_count++; +if (!check_indicate_seq (preorder_ctrl, pattrib->seq_num)) goto _err_exit; - } -/* s3. Insert all packet into Reorder Queue to maintain its ordering. */ if (!enqueue_reorder_recvframe (preorder_ctrl, prframe)) {
drivers/staging/rtl8723bs/hal/hal_com.c +0 -13
@@ -879,22 +879,9 @@ bool GetU1ByteIntegerFromStringInDecimal(char *Str, u8 *pInt)void rtw_hal_check_rxfifo_full (struct adapter *adapter) { -struct dvobj_priv *psdpriv = adapter->dvobj; -struct debug_priv *pdbgpriv = &psdpriv->drv_dbg; -int save_cnt = false; -/* switch counter to RX fifo */ /* printk("8723b or 8192e , MAC_667 set 0xf0\n"); */ rtw_write8 (adapter,REG_RXERR_RPT +3 ,rtw_read8 (adapter,REG_RXERR_RPT +3 )|0xf0 ); - save_cnt = true; -/* todo: other chips */ - -if (save_cnt) { -/* rtw_write8(adapter, REG_RXERR_RPT+3, rtw_read8(adapter, REG_RXERR_RPT+3)|0xa0); */ - pdbgpriv->dbg_rx_fifo_last_overflow = pdbgpriv->dbg_rx_fifo_curr_overflow; - pdbgpriv->dbg_rx_fifo_curr_overflow =rtw_read16 (adapter,REG_RXERR_RPT ); - pdbgpriv->dbg_rx_fifo_diff_overflow = pdbgpriv->dbg_rx_fifo_curr_overflow-pdbgpriv->dbg_rx_fifo_last_overflow; - } }#ifdef DBG_RX_SIGNAL_DISPLAY_RAW_DATA
drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +0 -4
@@ -307,8 +307,6 @@ s32 rtl8723b_FirmwareDownload(struct adapter *padapter, bool bUsedWoWLANFw)const struct firmware *fw;struct device *device =dvobj_to_dev (padapter->dvobj);u8 *fwfilepath; -struct dvobj_priv *psdpriv = padapter->dvobj; -struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;u8 tmp_ps; pFirmware =kzalloc (sizeof (struct rt_firmware ),GFP_KERNEL );
@@ -327,8 +325,6 @@ s32 rtl8723b_FirmwareDownload(struct adapter *padapter, bool bUsedWoWLANFw)/* 2. read power_state = 0xA0[1:0] */ tmp_ps =rtw_read8 (padapter,0xa0 ); tmp_ps &=0x03 ; -if (tmp_ps !=0x01 ) - pdbgpriv->dbg_downloadfw_pwr_state_cnt++; fwfilepath ="rtlwifi/rtl8723bs_nic.bin" ;
drivers/staging/rtl8723bs/hal/sdio_halinit.c +1 -7
@@ -887,9 +887,6 @@ static void CardDisableRTL8723BSdio(struct adapter *padapter)static u32 rtl8723bs_hal_deinit (struct adapter *padapter) { -struct dvobj_priv *psdpriv = padapter->dvobj; -struct debug_priv *pdbgpriv = &psdpriv->drv_dbg; -if (padapter->hw_init_completed) {if (adapter_to_pwrctl (padapter)->bips_processing) {if (padapter->netif_up) {
@@ -922,18 +919,15 @@ static u32 rtl8723bs_hal_deinit(struct adapter *padapter)adapter_to_pwrctl (padapter)->pre_ips_type =0 ; }else { - pdbgpriv->dbg_carddisable_cnt++;CardDisableRTL8723BSdio (padapter);adapter_to_pwrctl (padapter)->pre_ips_type =1 ; } }else { - pdbgpriv->dbg_carddisable_cnt++;CardDisableRTL8723BSdio (padapter); } - }else - pdbgpriv->dbg_deinit_fail_cnt++; + }return _SUCCESS; }
drivers/staging/rtl8723bs/include/drv_types.h +0 -41
53 lines not on this page · raw message
drivers/staging/rtl8723bs/os_dep/os_intfs.c +2 -13
@@ -1014,8 +1014,6 @@ void rtw_ndev_destructor(struct net_device *ndev)void rtw_dev_unload (struct adapter *padapter) {struct pwrctrl_priv *pwrctl =adapter_to_pwrctl (padapter); -struct dvobj_priv *pobjpriv = padapter->dvobj; -struct debug_priv *pdbgpriv = &pobjpriv->drv_dbg;struct cmd_priv *pcmdpriv = &padapter->cmdpriv;u8 cnt =0 ;
@@ -1045,7 +1043,6 @@ void rtw_dev_unload(struct adapter *padapter)/* check HW status and SW state */ netdev_dbg (padapter->pnetdev,"%s: driver in IPS-FWLPS\n" , __func__); - pdbgpriv->dbg_dev_unload_inIPS_cnt++;LeaveAllPowerSaveMode (padapter); }else { netdev_dbg(padapter->pnetdev,
@@ -1129,24 +1126,21 @@ static void rtw_suspend_normal(struct adapter *padapter)void rtw_suspend_common (struct adapter *padapter) {struct dvobj_priv *psdpriv = padapter->dvobj; -struct debug_priv *pdbgpriv = &psdpriv->drv_dbg;struct pwrctrl_priv *pwrpriv =dvobj_to_pwrctl (psdpriv);struct mlme_priv *pmlmepriv = &padapter->mlmepriv;unsigned long start_time = jiffies;netdev_dbg (padapter->pnetdev," suspend start\n" ); - pdbgpriv->dbg_suspend_cnt++; pwrpriv->bInSuspend = true;while (pwrpriv->bips_processing)msleep (1 ); -if ((!padapter->bup) || (padapter->bDriverStopped) || (padapter->bSurpriseRemoved)) { - pdbgpriv->dbg_suspend_error_cnt++; +if ((!padapter->bup) || (padapter->bDriverStopped) || (padapter->bSurpriseRemoved))return ; - } +rtw_ps_deny (padapter,PS_DENY_SUSPEND );rtw_cancel_all_timer (padapter);
@@ -1174,8 +1168,6 @@ static int rtw_resume_process_normal(struct adapter *padapter)struct net_device *pnetdev;struct pwrctrl_priv *pwrpriv;struct mlme_priv *pmlmepriv; -struct dvobj_priv *psdpriv; -struct debug_priv *pdbgpriv;int ret = _SUCCESS;
@@ -1187,8 +1179,6 @@ static int rtw_resume_process_normal(struct adapter *padapter) pnetdev = padapter->pnetdev; pwrpriv =adapter_to_pwrctl (padapter); pmlmepriv = &padapter->mlmepriv; - psdpriv = padapter->dvobj; - pdbgpriv = &psdpriv->drv_dbg;/* interface init */ /* if (sdio_init(adapter_to_dvobj(padapter)) != _SUCCESS) */ if ((padapter->intf_init) && (padapter->intf_init (adapter_to_dvobj (padapter)) != _SUCCESS)) {
@@ -1207,7 +1197,6 @@ static int rtw_resume_process_normal(struct adapter *padapter)if (pm_netdev_open (pnetdev, true) !=0 ) { ret =-1 ; - pdbgpriv->dbg_resume_error_cnt++; goto exit; }
drivers/staging/rtl8723bs/os_dep/sdio_intf.c +10 -35
110 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2029/3318 staging: rtl8723bs: disable SDIO function on block size failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit baa84b1bb1648506333fde3e66b6540f9d7d73cc ]
sdio_init() enables the SDIO function before configuring the block size. If sdio_set_block_size() fails, the function jumps to the release path and returns the error without disabling the SDIO function. The caller then frees the dvobj directly, so the enabled SDIO function is left active on that probe failure path.
Disable the SDIO function before releasing the host when block size configuration fails.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/rtl8723bs/os_dep/sdio_intf.c +3 -1
@@ -122,8 +122,10 @@ static u32 sdio_init(struct dvobj_priv *dvobj) goto release; err =sdio_set_block_size (func,512 ); -if (err) +if (err) { +sdio_disable_func (func); goto release; + } psdio_data->block_transfer_len =512 ; psdio_data->tx_block_mode =1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2030/3318 staging: octeon: schedule the TX cleanup tasklet every 1024th packet
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Orgad Shaneh <[email protected]>
[ Upstream commit db57f6517bf65523968ae29cd34a790bfa7d32af ]
cvm_oct_xmit() means to schedule the cleanup tasklet once every 1024 packets, as its comment says, to cover the pathological case of heavy traffic on one port delaying the cleanup of another port blocked waiting for it.
The test is inverted: total_to_clean & 0x3ff is true for 1023 of every 1024 values, and false only on the multiples of 1024. So the tasklet is scheduled on nearly every packet, and skipped on exactly the packet the comment wants. That costs one TASKLET softirq per transmitted packet, each walking every port and doing an FAU fetch-and-add per non-empty queue, and it buys nothing for this port, which already frees its completed skbs inline from the skb_to_free value it reads out of the FAU.
Test the mask against zero. On a CN50XX board (2 cores at 300MHz) carrying ~6.9k transmitted packets/s, TASKLET softirqs drop from 7133/s to 597/s with no throughput change; the freeing work is conserved, so this removes softirq entries, not work.
--- drivers/staging/octeon/ethernet-tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/octeon/ethernet-tx.c +1 -1
@@ -483,7 +483,7 @@ netdev_tx_t cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev)cvmx_fau_fetch_and_add32 (FAU_TOTAL_TX_TO_CLEAN ,1 ); } -if (total_to_clean &0x3ff ) { +if ((total_to_clean &0x3ff ) ==0 ) {/* * Schedule the cleanup tasklet every 1024 packets for * the pathological case of high traffic on one port
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2031/3318 clk: fix self-consuming provider module pinning
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jerome Brunet <[email protected]>
[ Upstream commit a1c8d531c694e193dc48ef2428877d5ea2e35134 ]
clk_hw_get_clk() lets a provider get a struct clk for one of its own struct clk_hw.
When a struct clk is created, the module usage count of the provider is unconditionally increased. For a self-consuming provider, this means it pins itself and the module can never be unloaded.
Increasing the module usage count should only be done when the consumer lives in a different module from the provider. Use THIS_MODULE to capture caller's module and increase the module usage count accordingly.
It is OK for consumer-only APIs such as clk_get() or of_clk_get() to pass a NULL owner. As a result, any provider module will get pinned, same as before.
--- drivers/clk/clk.c | 46 ++++++++++++++++++++---------------- drivers/clk/clk.h | 5 ++-- drivers/clk/clkdev.c | 4 ++-- include/linux/clk-provider.h | 22 ++++++++++++++--- 4 files changed, 50 insertions(+), 27 deletions(-)
drivers/clk/clk.c +26 -20
@@ -108,6 +108,7 @@ struct clk {unsigned long max_rate;unsigned int exclusive_count;struct hlist_node clks_node; +bool pinning; };/*** runtime pm ***/
@@ -4114,13 +4115,15 @@ static void free_clk(struct clk *clk)* @hw: clk_hw associated with the clk being consumed * @dev_id: string describing device name * @con_id: connection ID string on device +* @owner: reference to the module creating the clock * * This is the main function used to create a clk pointer for use by clk * consumers. It connects a consumer to the clk_core and clk_hw structures * used by the framework and clk provider respectively. */ struct clk *clk_hw_create_clk (struct device *dev,struct clk_hw *hw, -const char *dev_id,const char *con_id) +const char *dev_id,const char *con_id, +struct module *owner) {struct clk *clk;struct clk_core *core;
@@ -4135,7 +4138,13 @@ struct clk *clk_hw_create_clk(struct device *dev, struct clk_hw *hw,return clk; clk->dev = dev; -if (!try_module_get (core->owner)) { +/* +* Pin the provider module only when the consumer lives in a different +* module. A provider getting a clk from its own clk_hw would otherwise +* pin itself and could never be unloaded. +*/ + clk->pinning = owner != core->owner; +if (clk->pinning && !try_module_get (core->owner)) {free_clk (clk);return ERR_PTR (-ENOENT ); }
@@ -4146,24 +4155,19 @@ struct clk *clk_hw_create_clk(struct device *dev, struct clk_hw *hw,return clk; } -/** -* clk_hw_get_clk - get clk consumer given an clk_hw -* @hw: clk_hw associated with the clk being consumed -* @con_id: connection ID string on device -* -* Returns: new clk consumer -* This is the function to be used by providers which need -* to get a consumer clk and act on the clock element -* Calls to this function must be balanced with calls clk_put() +/* +* Internal helper backing the clk_hw_get_clk() macro, which passes the caller's +* module via THIS_MODULE. */ -struct clk *clk_hw_get_clk (struct clk_hw *hw,const char *con_id) +struct clk *__clk_hw_get_clk (struct clk_hw *hw,const char *con_id, +struct module *owner) {struct device *dev = hw->core->dev;const char *name = dev ?dev_name (dev) :NULL ; -return clk_hw_create_clk (dev, hw, name, con_id); +return clk_hw_create_clk (dev, hw, name, con_id, owner); } -EXPORT_SYMBOL (clk_hw_get_clk); +EXPORT_SYMBOL (__clk_hw_get_clk);static int clk_cpy_name (const char **dst_p,const char *src,bool must_exist) {
@@ -4327,8 +4331,9 @@ __clk_register(struct device *dev, struct device_node *np, struct clk_hw *hw)INIT_HLIST_HEAD (&core->clks);/* -* Don't call clk_hw_create_clk() here because that would pin the -* provider module to itself and prevent it from ever being removed. +* Don't call clk_hw_create_clk() here because it would systematically +* add a consumer to the hw clock and all clocks would appear to have +* consumer in the clock summary. */ hw->clk =alloc_clk (core,NULL ,NULL );if (IS_ERR (hw->clk)) {
@@ -4677,7 +4682,7 @@ struct clk *devm_clk_hw_get_clk(struct device *dev, struct clk_hw *hw,if (!clkp)return ERR_PTR (-ENOMEM ); - clk =clk_hw_get_clk (hw, con_id); + clk =__clk_hw_get_clk (hw, con_id, dev->driver->owner);if (!IS_ERR (clk)) { *clkp = clk;devres_add (dev, clkp);
@@ -4724,7 +4729,8 @@ void __clk_put(struct clk *clk) owner = clk->core->owner;kref_put (&clk->core->ref, __clk_release); -module_put (owner); +if (clk->pinning) +module_put (owner);free_clk (clk); }
@@ -5245,7 +5251,7 @@ struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec) {struct clk_hw *hw =of_clk_get_hw_from_clkspec (clkspec); -return clk_hw_create_clk (NULL , hw,NULL , __func__); +return clk_hw_create_clk (NULL , hw,NULL , __func__,NULL ); }EXPORT_SYMBOL_GPL (of_clk_get_from_provider);
@@ -5272,7 +5278,7 @@ static struct clk *__of_clk_get(struct device_node *np, {struct clk_hw *hw =of_clk_get_hw (np, index, con_id); -return clk_hw_create_clk (NULL , hw, dev_id, con_id); +return clk_hw_create_clk (NULL , hw, dev_id, con_id,NULL ); }struct clk *of_clk_get (struct device_node *np,int index)
drivers/clk/clk.h +3 -2
@@ -23,13 +23,14 @@ struct clk_hw *clk_find_hw(const char *dev_id, const char *con_id);#ifdef CONFIG_COMMON_CLK struct clk *clk_hw_create_clk (struct device *dev,struct clk_hw *hw, -const char *dev_id,const char *con_id); +const char *dev_id,const char *con_id, +struct module *owner);void __clk_put (struct clk *clk);#else /* All these casts to avoid ifdefs in clkdev... */ static inline struct clk *clk_hw_create_clk (struct device *dev,struct clk_hw *hw,const char *dev_id, -const char *con_id) +const char *con_id,struct module *owner) {return (struct clk *)hw; }
drivers/clk/clkdev.c +2 -2
@@ -88,7 +88,7 @@ static struct clk *__clk_get_sys(struct device *dev, const char *dev_id, {struct clk_hw *hw =clk_find_hw (dev_id, con_id); -return clk_hw_create_clk (dev, hw, dev_id, con_id); +return clk_hw_create_clk (dev, hw, dev_id, con_id,NULL ); }struct clk *clk_get_sys (const char *dev_id,const char *con_id)
@@ -105,7 +105,7 @@ struct clk *clk_get(struct device *dev, const char *con_id)if (dev && dev->of_node) { hw =of_clk_get_hw (dev->of_node,0 , con_id);if (!IS_ERR (hw) ||PTR_ERR (hw) == -EPROBE_DEFER ) -return clk_hw_create_clk (dev, hw, dev_id, con_id); +return clk_hw_create_clk (dev, hw, dev_id, con_id,NULL ); }return __clk_get_sys (dev, dev_id, con_id);
include/linux/clk-provider.h +19 -3
@@ -37,6 +37,7 @@ struct clk;struct clk_hw ;struct clk_core ;struct dentry ; +struct module ;/** * struct clk_rate_request - Structure encoding the clk constraints that
@@ -316,8 +317,9 @@ struct clk_init_data {* @core: pointer to the struct clk_core instance that points back to this * struct clk_hw instance * -* @clk: pointer to the per-user struct clk instance that can be used to call -* into the clk API +* @clk: pointer to the per-user struct clk instance. This will be removed at +* some point in the future, Please consider the field obsolete and do not use +* it. Use clk_hw_get_clk() to get a per-user struct clk from a struct clk_hw. * * @init: pointer to struct clk_init_data that contains the init data shared * with the common clock framework. This pointer will be set to NULL once
@@ -1305,10 +1307,24 @@ static inline struct clk_hw *__clk_get_hw(struct clk *clk) }#endif -struct clk *clk_hw_get_clk (struct clk_hw *hw,const char *con_id); +struct clk *__clk_hw_get_clk (struct clk_hw *hw,const char *con_id, +struct module *owner);struct clk *devm_clk_hw_get_clk (struct device *dev,struct clk_hw *hw,const char *con_id); +/** +* clk_hw_get_clk - get clk consumer given a clk_hw +* @hw: clk_hw associated with the clk being consumed +* @con_id: connection ID string on device +* +* Return: new clk consumer +* This is the function to be used by providers which need +* to get a consumer clk and act on the clock element +* Calls to this function must be balanced with calls to clk_put() +*/ +#define clk_hw_get_clk (hw, con_id) \ + __clk_hw_get_clk((hw), (con_id), THIS_MODULE) +unsigned int clk_hw_get_num_parents (const struct clk_hw *hw);struct clk_hw *clk_hw_get_parent (const struct clk_hw *hw); struct clk_hw *clk_hw_get_parent_by_index(const struct clk_hw *hw,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2032/3318 microblaze: CCF: fix refcount leak
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander A. Klimov <[email protected]>
[ Upstream commit aeedf85beac51c7cd8f7bf4c918a0104dfdb8b78 ]
Every value returned from of_clk_get() is supposed to be cleaned up via clk_put() once not needed anymore.
--- arch/microblaze/kernel/cpu/cpuinfo.c | 1 + 1 file changed, 1 insertion(+)
arch/microblaze/kernel/cpu/cpuinfo.c +1 -0
@@ -133,6 +133,7 @@ void __init setup_cpuinfo_clk(void) cpuinfo.cpu_clock_freq =fcpu (cpu,"timebase-frequency" ); }else { cpuinfo.cpu_clock_freq =clk_get_rate (clk); +clk_put (clk); }if (!cpuinfo.cpu_clock_freq) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2033/3318 microblaze: prevent ptrace writes to MSR and pt_mode
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérémy Jean <[email protected]>
[ Upstream commit 8518fd17ccef4a7d77877ccb0403b722106ad1a4 ]
arch_ptrace() accepts PTRACE_POKEUSR for every aligned offset below PT_SIZE. This includes the saved machine status register and pt_mode, which are kernel-owned execution state rather than general registers.
On return from an exception, rtbd copies MSR_UMS to the live MSR_UM bit. An unprivileged same-UID tracer can therefore clear MSR_UMS in its tracee's saved register frame and make the tracee resume in supervisor mode. pt_mode also controls whether later entry paths classify the frame as kernel or user state.
Reject PTRACE_POKEUSR writes to both fields while retaining read access.
--- arch/microblaze/kernel/ptrace.c | 3 +++ 1 file changed, 3 insertions(+)
arch/microblaze/kernel/ptrace.c +3 -0
@@ -101,6 +101,9 @@ long arch_ptrace(struct task_struct *child, long request, }else { rval = -EIO ; } + }else if (request ==PTRACE_POKEUSR && + (addr ==PT_MSR || addr ==PT_MODE )) { + rval = -EIO ; }else if (addr <PT_SIZE && (addr &0x3 ) ==0 ) {microblaze_reg_t *reg_addr =reg_save_addr (addr, child);if (request ==PTRACE_PEEKUSR )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2034/3318 soundwire: intel: initialise quirk_mask before reading it
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Boris Faure <[email protected]>
[ Upstream commit ee8a8cfe4e8d3c67456e554c988017c252710a25 ]
sdw_master_read_intel_prop() declares quirk_mask without an initialiser and ignores the return value of fwnode_property_read_u32(). When a BIOS does not describe "intel-quirk-mask" for a link, the property read leaves the variable untouched and stack garbage decides whether SDW_INTEL_QUIRK_MASK_BUS_DISABLE is honoured, so the link may be marked hw_disabled at random.
Initialise it to 0, matching is_link_enabled() in sound/hda/core/intel-sdw-acpi.c.
Found by code inspection, not observed at run time.
--- drivers/soundwire/intel_auxdevice.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soundwire/intel_auxdevice.c +1 -1
@@ -124,7 +124,7 @@ static int sdw_master_read_intel_prop(struct sdw_bus *bus)struct sdw_master_prop *prop = &bus->prop;struct fwnode_handle *link;char name[32 ]; -u32 quirk_mask; +u32 quirk_mask =0 ;/* Find master handle */ snprintf(name, sizeof(name),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2035/3318 wifi: rtw88: debugfs: dont vzalloc(0) when rsvd_page is read unconfigured
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdurrahman Karadag <[email protected]>
[ Upstream commit 81510c3d6f2199889a4a936d8cf8b9e05911b10e ]
Reading the rsvd_page debugfs entry before writing a page offset and count to it calls vzalloc() with a size of zero, because rsvd_page.page_num defaults to 0. vmalloc warns about this:
WARNING: mm/vmalloc.c:4019 at __vmalloc_node_range_noprof+0x9ac/0xa30 ... Call Trace: __vmalloc_node_noprof+0x4c/0x70 rtw_debugfs_get_rsvd_page+0x4c/0x110 [rtw88_core] seq_read_iter+0x132/0x4b0 seq_read+0x12e/0x1c0 full_proxy_read+0x6f/0xc0 vfs_read+0xdd/0x490
rtw_fw_dump_fifo() would reject the zero size anyway, but only after the allocation. Check for a zero buffer size first and print a short usage hint instead of allocating.
--- drivers/net/wireless/realtek/rtw88/debug.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/wireless/realtek/rtw88/debug.c +5 -0
@@ -315,6 +315,11 @@ static int rtw_debugfs_get_rsvd_page(struct seq_file *m, void *v)int i;int ret; +if (!buf_size) { +seq_puts (m,"usage: echo <page_offset> <page_num> > rsvd_page\n" ); +return 0 ; + } + buf =vzalloc (buf_size);if (!buf)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2036/3318 dlm: validate lock modes in recovery messages
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Danila Chernetsov <[email protected]>
[ Upstream commit 7bf1aca6d626944091a5cb218b4e487547edff0a ]
The DLM recovery path restores lock state from rcom_lock messages received from remote nodes. The lock modes in these messages are copied directly into the local lkb state without validating that they are within the valid DLM lock mode range.
The rest of the DLM code assumes that lkb_rqmode and lkb_grmode contain valid lock modes. In particular, LVB callback handling in dlm_may_skip_callback() uses lock modes as indexes into the dlm_lvb_operations array:
dlm_lvb_operations[prev_mode + 1][mode + 1]
An invalid lock mode received during recovery could therefore result in an out-of-bounds read during subsequent LVB callback processing.
Validate rl_rqmode and rl_grmode before storing them into the local LKB state. This preserves the lock mode invariant required by the rest of the DLM code.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- fs/dlm/lock.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/dlm/lock.c +4 -0
@@ -5345,6 +5345,10 @@ static int receive_rcom_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb, {struct rcom_lock *rl = (struct rcom_lock *) rc->rc_buf; +if (rl->rl_rqmode <DLM_LOCK_IV || rl->rl_rqmode >DLM_LOCK_EX || + rl->rl_grmode <DLM_LOCK_IV || rl->rl_grmode >DLM_LOCK_EX ) +return -EINVAL ; + lkb->lkb_nodeid =le32_to_cpu (rc->rc_header.h_nodeid); lkb->lkb_ownpid =le32_to_cpu (rl->rl_ownpid); lkb->lkb_remid =le32_to_cpu (rl->rl_lkid);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2037/3318 remoteproc: imx_dsp_rproc: Add support of recovery and coredump process
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shengjiu Wang <[email protected]>
[ Upstream commit c4c432dfb00fcb69d56cc9778f527cce71cec9bb ]
When enabled FW recovery, but is broken because software reset is missed in this recovery flow. So move software reset from imx_dsp_runtime_resume() to .load() and clear memory before loading firmware to make recovery work.
Add call rproc_coredump_set_elf_info() to initialize the elf info for coredump, otherwise coredump will report error "ELF class is not set".
Stable-dep-of: 13df1fa4f1a3 ("remoteproc: imx_dsp: Acquire runtime PM before adding carveouts")
--- drivers/remoteproc/imx_dsp_rproc.c | 45 +++++++++++++++++++----------- 1 file changed, 29 insertions(+), 16 deletions(-)
drivers/remoteproc/imx_dsp_rproc.c +29 -16
@@ -684,7 +684,6 @@ static int imx_dsp_rproc_prepare(struct rproc *rproc) {struct imx_dsp_rproc *priv = rproc->priv;struct device *dev = rproc->dev.parent; -struct rproc_mem_entry *carveout;int ret; ret =imx_dsp_rproc_add_carveout (priv);
@@ -695,15 +694,6 @@ static int imx_dsp_rproc_prepare(struct rproc *rproc)pm_runtime_get_sync (dev); -/* -* Clear buffers after pm rumtime for internal ocram is not -* accessible if power and clock are not enabled. -*/ -list_for_each_entry (carveout, &rproc->carveouts, node) { -if (carveout->va) -memset (carveout->va,0 , carveout->len); - } -return 0 ; }
@@ -932,13 +922,39 @@ static int imx_dsp_rproc_parse_fw(struct rproc *rproc, const struct firmware *fwreturn 0 ; } +static int imx_dsp_rproc_load (struct rproc *rproc,const struct firmware *fw) +{ +struct imx_dsp_rproc *priv = rproc->priv; +const struct imx_dsp_rproc_dcfg *dsp_dcfg = priv->dsp_dcfg; +struct rproc_mem_entry *carveout; +int ret; + +/* Reset DSP if needed */ +if (dsp_dcfg->reset) + dsp_dcfg->reset (priv); +/* +* Clear buffers after pm rumtime for internal ocram is not +* accessible if power and clock are not enabled. +*/ +list_for_each_entry (carveout, &rproc->carveouts, node) { +if (carveout->va) +memset (carveout->va,0 , carveout->len); + } + + ret =imx_dsp_rproc_elf_load_segments (rproc, fw); +if (ret) +return ret; + +return 0 ; +} +static const struct rproc_ops imx_dsp_rproc_ops = { .prepare = imx_dsp_rproc_prepare, .unprepare = imx_dsp_rproc_unprepare, .start = imx_dsp_rproc_start, .stop = imx_dsp_rproc_stop, .kick = imx_dsp_rproc_kick, - .load = imx_dsp_rproc_elf_load_segments, + .load = imx_dsp_rproc_load, .parse_fw = imx_dsp_rproc_parse_fw, .sanity_check = rproc_elf_sanity_check, .get_boot_addr = rproc_elf_get_boot_addr,
@@ -1148,6 +1164,8 @@ static int imx_dsp_rproc_probe(struct platform_device *pdev) goto err_detach_domains; } +rproc_coredump_set_elf_info (rproc,ELFCLASS32 ,EM_XTENSA ); +pm_runtime_enable (dev);return 0 ;
@@ -1176,7 +1194,6 @@ static int imx_dsp_runtime_resume(struct device *dev) {struct rproc *rproc =dev_get_drvdata (dev);struct imx_dsp_rproc *priv = rproc->priv; -const struct imx_dsp_rproc_dcfg *dsp_dcfg = priv->dsp_dcfg;int ret;/*
@@ -1197,10 +1214,6 @@ static int imx_dsp_runtime_resume(struct device *dev)return ret; } -/* Reset DSP if needed */ -if (dsp_dcfg->reset) - dsp_dcfg->reset (priv); -return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2038/3318 remoteproc: imx_dsp_rproc: Drop extra space
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peng Fan <[email protected]>
[ Upstream commit 8049dc7b631e33a42d8413fe48b043113afa914c ]
Drop extra space between return and zero.
Stable-dep-of: 13df1fa4f1a3 ("remoteproc: imx_dsp: Acquire runtime PM before adding carveouts")
--- drivers/remoteproc/imx_dsp_rproc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/remoteproc/imx_dsp_rproc.c +2 -2
@@ -694,7 +694,7 @@ static int imx_dsp_rproc_prepare(struct rproc *rproc)pm_runtime_get_sync (dev); -return 0 ; +return 0 ; }/* Unprepare function for rproc_ops */
@@ -702,7 +702,7 @@ static int imx_dsp_rproc_unprepare(struct rproc *rproc) {pm_runtime_put_sync (rproc->dev.parent); -return 0 ; +return 0 ; }/* Kick function for rproc_ops */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2039/3318 remoteproc: imx_dsp: Acquire runtime PM before adding carveouts
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 13df1fa4f1a30571442eda64c73d6cac7b9b5c95 ]
The prepare callback publishes DSP carveouts before acquiring the runtime-PM reference that establishes required clocks and mailbox state. A PM failure therefore leaves the prepare transaction partially published.
Acquire runtime PM first and drop that reference if carveout construction fails, so a failed prepare does not add resources before its hardware prerequisite.
--- drivers/remoteproc/imx_dsp_rproc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/remoteproc/imx_dsp_rproc.c +5 -2
@@ -686,14 +686,17 @@ static int imx_dsp_rproc_prepare(struct rproc *rproc)struct device *dev = rproc->dev.parent;int ret; + ret =pm_runtime_resume_and_get (dev); +if (ret <0 ) +return ret; + ret =imx_dsp_rproc_add_carveout (priv);if (ret) {dev_err (dev,"failed on imx_dsp_rproc_add_carveout\n" ); +pm_runtime_put_sync (dev);return ret; } -pm_runtime_get_sync (dev); -return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2040/3318 x86/crash: Reserve elfcorehdr for CONFIG_NR_CPUS, not CONFIG_NR_CPUS_DEFAULT
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ionut Nechita <[email protected]>
[ Upstream commit 6664ad1026b558563702f9a1ce637df33e7c001e ]
NR_CPUS_DEFAULT is purely a Kconfig thing. Its entire purpose in life is to start NR_CPUS at a sane value. There is precisely one (buggy) reference to it outside of Kconfig in the whole kernel: the x86 crash code.
That code undersizes the elfcorehdr reservation whenever NR_CPUS exceeds NR_CPUS_DEFAULT, because the header carries one phdr per possible CPU and num_possible_cpus() is bounded by NR_CPUS. kexec_file_load(2) then fails with -EINVAL from sanity_check_segment_list(), and kexec_load(2) silently truncates the elfcorehdr, which surfaces later as a bad or unusable dump.
Size the elfcorehdr reservation with NR_CPUS instead.
--- arch/x86/kernel/crash.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/crash.c +3 -3
@@ -363,9 +363,9 @@ int crash_load_segments(struct kimage *image)* maximum CPUs and maximum memory ranges. */ if (IS_ENABLED (CONFIG_MEMORY_HOTPLUG )) - pnum =2 +CONFIG_NR_CPUS_DEFAULT +CONFIG_CRASH_MAX_MEMORY_RANGES ; + pnum =2 +CONFIG_NR_CPUS +CONFIG_CRASH_MAX_MEMORY_RANGES ;else - pnum +=2 +CONFIG_NR_CPUS_DEFAULT ; + pnum +=2 +CONFIG_NR_CPUS ;if (pnum < (unsigned long )PN_XNUM ) { kbuf.memsz = pnum *sizeof (Elf64_Phdr);
@@ -418,7 +418,7 @@ unsigned int arch_crash_get_elfcorehdr_size(void)unsigned int sz;/* kernel_map, VMCOREINFO and maximum CPUs */ - sz =2 +CONFIG_NR_CPUS_DEFAULT ; + sz =2 +CONFIG_NR_CPUS ;if (IS_ENABLED (CONFIG_MEMORY_HOTPLUG )) sz +=CONFIG_CRASH_MAX_MEMORY_RANGES ; sz *=sizeof (Elf64_Phdr);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2041/3318 bpftool: Set BPF_F_XDP_DEV_BOUND_ONLY flag non-destructively
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Toke Høiland-Jørgensen <[email protected]>
[ Upstream commit 06d6f845c4bda857a6ae864690f35321b878e827 ]
When setting the XDP hints ifname, bpftool would set the BPF_F_XDP_DEV_BOUND_ONLY without looking at the existing program flags, overriding any other flag values. This was always a destructive action, but after we change libbpf to carry the frags section flag in prog_flags, this can impact bpftool loading of XDP frags programs.
Change the flag setting to be non-destructive by OR'ing it with the existing flags.
--- tools/bpf/bpftool/prog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/bpf/bpftool/prog.c +1 -1
@@ -1709,7 +1709,7 @@ static int load_with_options(int argc, char **argv, bool first_prog_only) }if (prog_type ==BPF_PROG_TYPE_XDP && xdpmeta_ifindex) { -bpf_program__set_flags (pos,BPF_F_XDP_DEV_BOUND_ONLY ); +bpf_program__set_flags (pos,bpf_program__flags (pos) |BPF_F_XDP_DEV_BOUND_ONLY );bpf_program__set_ifindex (pos, xdpmeta_ifindex); }else {bpf_program__set_ifindex (pos, offload_ifindex);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2042/3318 PCI: endpoint: pci-epf-vntb: Pass PF/VF number when BAR programming
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Koichiro Den <[email protected]>
[ Upstream commit afe2aa9dc93d904730bab63f5ccb514a318e6464 ]
vntb_epf_mw_set_trans() programs the memory-window BAR through pci_epc_set_bar() with hardcoded function numbers (0, 0), so the BAR lands on the wrong function whenever the vNTB EPF is bound to anything but PF0. The other BAR programming sites in the vNTB driver already pass the EPF's own numbers.
Pass the EPF's own func_no/vfunc_no here as well.
--- drivers/pci/endpoint/functions/pci-epf-vntb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/endpoint/functions/pci-epf-vntb.c +2 -1
@@ -1076,7 +1076,8 @@ static int vntb_epf_mw_set_trans(struct ntb_dev *ndev, int pidx, int idx, epf_bar->barno = barno; epf_bar->size = size; - ret =pci_epc_set_bar (ntb->epf->epc,0 ,0 , epf_bar); + ret =pci_epc_set_bar (ntb->epf->epc, ntb->epf->func_no, + ntb->epf->vfunc_no, epf_bar);if (ret) {dev_err (dev,"failure set mw trans\n" );return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2043/3318 dmaengine: fsl_raid: dont invoke client callback under desc_lock
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 62c267ce97444f8a381f2bb3cd5d534eb362c540 ]
fsl_re_dequeue() holds re_chan->desc_lock while calling fsl_re_desc_done(), which synchronously invokes the DMA client completion callback via dmaengine_desc_get_callback_invoke(). If that callback submits new work (e.g. fsl_re_tx_submit()), it tries to reacquire the same desc_lock and deadlocks on the spinlock.
Collect completed descriptors into a local list under the lock, then release the lock and invoke the callbacks before moving the descriptors to the ack queue.
--- drivers/dma/fsl_raid.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/dma/fsl_raid.c +13 -2
@@ -162,6 +162,7 @@ static void fsl_re_dequeue(struct tasklet_struct *t)struct fsl_re_hw_desc *hwdesc;unsigned long flags;unsigned int count, oub_count; +LIST_HEAD (completed);int found;fsl_re_cleanup_descs (re_chan);
@@ -182,8 +183,7 @@ static void fsl_re_dequeue(struct tasklet_struct *t) }if (found) { -fsl_re_desc_done (desc); -list_move_tail (&desc->node, &re_chan->ack_q); +list_move_tail (&desc->node, &completed); }else {dev_err (re_chan->dev,"found hwdesc not in sw queue, discard it\n" );
@@ -196,6 +196,17 @@ static void fsl_re_dequeue(struct tasklet_struct *t) FSL_RE_RMVD_JOB(1)); }spin_unlock_irqrestore (&re_chan->desc_lock, flags); + +/* Invoke the client callbacks outside the channel lock. The callback +* may submit new work which re-acquires desc_lock, so holding it here +* would deadlock. +*/ +list_for_each_entry_safe (desc, _desc, &completed, node) { +fsl_re_desc_done (desc); +spin_lock_irqsave (&re_chan->desc_lock, flags); +list_move_tail (&desc->node, &re_chan->ack_q); +spin_unlock_irqrestore (&re_chan->desc_lock, flags); + } }/* Per Job Ring interrupt handler */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2044/3318 dmaengine: fsl_raid: avoid free_q underflow in free_chan_resources
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit d805aa5b6088b193debabaa80cc0991bfa2bd057 ]
fsl_re_free_chan_resources() loops alloc_count times calling list_first_entry() on free_q without checking whether the list still has entries. If descriptors remain un-acked or pending in submit_q / active_q / ack_q when the channel resources are freed, free_q becomes smaller than alloc_count and list_first_entry() returns the list head, causing list_del() to corrupt the list head and dereference a bogus pointer.
Walk free_q with list_for_each_entry_safe() until it is empty, decrementing alloc_count per freed descriptor, instead of relying on the alloc_count count.
--- drivers/dma/fsl_raid.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/dma/fsl_raid.c +3 -6
@@ -613,18 +613,15 @@ static int fsl_re_alloc_chan_resources(struct dma_chan *chan)static void fsl_re_free_chan_resources (struct dma_chan *chan) {struct fsl_re_chan *re_chan; -struct fsl_re_desc *desc; +struct fsl_re_desc *desc, *_desc; re_chan = container_of(chan, struct fsl_re_chan, chan); -while (re_chan->alloc_count--) { - desc =list_first_entry (&re_chan->free_q, - struct fsl_re_desc, - node); - +list_for_each_entry_safe (desc, _desc, &re_chan->free_q, node) {list_del (&desc->node);dma_pool_free (re_chan->re_dev->cf_desc_pool, desc->cf_addr, desc->cf_paddr);kfree (desc); + re_chan->alloc_count--; }if (!list_empty (&re_chan->free_q))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2045/3318 clk: Use the generic OF phandle parsing in only one place
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miquel Raynal (Schneider Electric) <[email protected]>
[ Upstream commit 57d728b4ab15a8af890013bb0f302e7733f7c1c6 ]
Ideally, there should be one single entry in the OF world. This way, the DT parsing logic is always identical. At this stage, we call of_parse_phandle_with_args() in:
- of_parse_clkspec()
- of_clk_get_parent_name()
which kinds of defeats the above statement. Furthermore, when this call is done from of_clk_get_parent_name(), we fail to parse the 'clock-ranges' property.
Make sure DT world is entered only once by calling of_parse_clkspec() from of_clk_get_parent_name(). Doing so implies that we do not try the "clock-ranges" path if we already found a "clocks" property.
--- drivers/clk/clk.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/clk/clk.c +3 -2
@@ -5189,6 +5189,8 @@ static int of_parse_clkspec(const struct device_node *np, int index,* has a "clock-ranges" property, then we can try one of its * clocks. */ +if (of_property_present (np,"clocks" )) +break ; np = np->parent;if (np && !of_get_property (np,"clock-ranges" ,NULL ))break ;
@@ -5333,8 +5335,7 @@ const char *of_clk_get_parent_name(const struct device_node *np, int index)int count;struct clk *clk; - rc =of_parse_phandle_with_args (np,"clocks" ,"#clock-cells" , index, - &clkspec); + rc =of_parse_clkspec (np, index,NULL , &clkspec);if (rc)return NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2046/3318 selftests/clone3: tighten CLONE_CLEAR_SIGHAND conflict test
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Dolan <[email protected]>
[ Upstream commit aeebb4884f0e8feb9929f013067488b7f2081f33 ]
The CLONE_CLEAR_SIGHAND test intends to verify that CLONE_CLEAR_SIGHAND and CLONE_SIGHAND are mutually exclusive. However, CLONE_SIGHAND without CLONE_VM is independently invalid, so the test input has another reason to fail with EINVAL.
Add CLONE_VM so that CLONE_SIGHAND is otherwise valid, and require clone3() to fail with EINVAL. This ensures the test exercises the intended flag conflict and does not accept an unrelated failure.
--- tools/testing/selftests/clone3/clone3_clear_sighand.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/clone3/clone3_clear_sighand.c +3 -3
@@ -54,12 +54,12 @@ static void test_clone3_clear_sighand(void)* Check that CLONE_CLEAR_SIGHAND and CLONE_SIGHAND are mutually * exclusive. */ - args.flags |=CLONE_CLEAR_SIGHAND |CLONE_SIGHAND ; + args.flags |=CLONE_VM |CLONE_CLEAR_SIGHAND |CLONE_SIGHAND ; args.exit_signal =SIGCHLD ; pid =sys_clone3 (&args,sizeof (args)); -if (pid >0 ) +if (pid !=-1 || errno !=EINVAL )ksft_exit_fail_msg ( -"clone3(CLONE_CLEAR_SIGHAND | CLONE_SIGHAND) succeeded\n" ); +"clone3(CLONE_CLEAR_SIGHAND | CLONE_SIGHAND) did not fail with EINVAL\n" ); act.sa_handler = nop_handler; ret =sigemptyset (&act.sa_mask);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2047/3318 wifi: mac80211: fix unauthorised port check for encap offload
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit d59b9bf7df49367e01b06e82dd0f6e7ad3be493c ]
The check in ieee80211_tx_dequeue() reads frame_control, addr1 and addr2 out of the skb, but for encapsulation offload that's just a random part of the ethernet addresses, so dropping depends on bits in the destination address. This is obviously wrong.
Refactor the check and short-circuit for ethernet format frames, it only needs the port-control flag check since those are locally generated and not forwarded frames.
--- net/mac80211/tx.c | 48 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 14 deletions(-)
net/mac80211/tx.c +34 -14
@@ -3831,6 +3831,38 @@ static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata,return true; } +static bool ieee80211_drop_unauth_port (struct ieee80211_tx_data *tx) +{ +struct ieee80211_tx_info *info =IEEE80211_SKB_CB (tx->skb); +struct ieee80211_hdr *hdr; + +if (likely (test_sta_flag (tx->sta,WLAN_STA_AUTHORIZED ))) +return false; + +if (info->flags &IEEE80211_TX_CTL_INJECTED ) +return false; + +if (ieee80211_vif_is_mesh (&tx->sdata->vif) || + tx->sdata->vif.type ==NL80211_IFTYPE_OCB ) +return false; + +/* no need to check forwarding here */ +if (info->flags &IEEE80211_TX_CTL_HW_80211_ENCAP ) +return !(info->control.flags &IEEE80211_TX_CTRL_PORT_CTRL_PROTO ); + + hdr = (struct ieee80211_hdr *)tx->skb->data; + +if (!ieee80211_is_data_present (hdr->frame_control) || +is_multicast_ether_addr (hdr->addr1)) +return false; + +if ((info->control.flags &IEEE80211_TX_CTRL_PORT_CTRL_PROTO ) && +ieee80211_is_our_addr (tx->sdata, hdr->addr2,NULL )) +return false; + +return true; +} +struct sk_buff *ieee80211_tx_dequeue (struct ieee80211_hw *hw,struct ieee80211_txq *txq) {
@@ -3897,20 +3929,8 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,if (txq->sta) { tx.sta = container_of(txq->sta, struct sta_info, sta); -/* -* Drop unicast frames to unauthorised stations unless they are -* injected frames or EAPOL frames from the local station. -*/ -if (unlikely (!(info->flags &IEEE80211_TX_CTL_INJECTED ) && -ieee80211_is_data_present (hdr->frame_control) && - !ieee80211_vif_is_mesh (&tx.sdata->vif) && - tx.sdata->vif.type !=NL80211_IFTYPE_OCB && - !is_multicast_ether_addr (hdr->addr1) && - !test_sta_flag (tx.sta,WLAN_STA_AUTHORIZED ) && - (!(info->control.flags & -IEEE80211_TX_CTRL_PORT_CTRL_PROTO ) || - !ieee80211_is_our_addr (tx.sdata, hdr->addr2, -NULL )))) { + +if (unlikely (ieee80211_drop_unauth_port (&tx))) {I802_DEBUG_INC (local->tx_handlers_drop_unauth_port);ieee80211_free_txskb (&local->hw, skb); goto begin;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2048/3318 wifi: mac80211: fix key selection for encap offload frames
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 0e80db08668b560b3522849cb705623148bcd4b5 ]
ieee80211_tx_h_select_key() assumes the frame is in 802.11 format for picking the key, at least when there's no pairwise TK for the STA to transmit with.
For unicast this is likely not relevant because if there's no pairwise TK for the STA there's probably not going to be any other key either. But multicast encapsulation offload frames have no STA, so it looks at the ethernet header as if it was 802.11. This may not matter very much since multicast encapsulation offload is likely to ignore the key selection, but it's still wrong.
Create a separate selection function that doesn't (need to) look at the frame header - it's data anyway, so either unicast to a station (with sta pointer) or multicast. For MLO, the driver has to duplicate the frame and select the key anyway, so just skip it in that case entirely.
--- net/mac80211/tx.c | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-)
net/mac80211/tx.c +31 -6
@@ -588,6 +588,34 @@ ieee80211_select_link_key(struct ieee80211_tx_data *tx)return NULL ; } +/* +* An 802.3 frame is always a data frame, so there are no 802.11 addresses to +* look at: with a station the pairwise key is all that can apply, without one +* the frame is group addressed. On an MLD the driver has to pick the group key +* itself, as the same frame goes out on several links that each have their own. +*/ +static ieee80211_tx_result +ieee80211_select_key_8023 (struct ieee80211_tx_data *tx) +{ +struct ieee80211_tx_info *info =IEEE80211_SKB_CB (tx->skb); + +if (unlikely (info->flags &IEEE80211_TX_INTFL_DONT_ENCRYPT )) +return TX_CONTINUE ; + +if (tx->sta) { + tx->key =rcu_dereference (tx->sta->ptk[tx->sta->ptk_idx]); +if (!tx->key) + tx->key =rcu_dereference (tx->sdata->default_unicast_key); + }else if (!ieee80211_vif_is_mld (&tx->sdata->vif)) { + tx->key =rcu_dereference (tx->sdata->deflink.default_multicast_key); + } + +if (tx->key && tx->key->flags &KEY_FLAG_UPLOADED_TO_HARDWARE ) + info->control.hw_key = &tx->key->conf; + +return TX_CONTINUE ; +} + static ieee80211_tx_result debug_noinlineieee80211_tx_h_select_key (struct ieee80211_tx_data *tx) {
@@ -595,6 +623,9 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)struct ieee80211_tx_info *info =IEEE80211_SKB_CB (tx->skb);struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; +if (info->control.flags &IEEE80211_TX_CTL_HW_80211_ENCAP ) +return ieee80211_select_key_8023 (tx); +if (unlikely (info->flags &IEEE80211_TX_INTFL_DONT_ENCRYPT )) { tx->key =NULL ;return TX_CONTINUE ;
@@ -611,12 +642,6 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)else tx->key =NULL ; -if (info->flags &IEEE80211_TX_CTL_HW_80211_ENCAP ) { -if (tx->key && tx->key->flags &KEY_FLAG_UPLOADED_TO_HARDWARE ) - info->control.hw_key = &tx->key->conf; -return TX_CONTINUE ; - } -if (tx->key) {bool skip_hw = false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2049/3318 wifi: mac80211: dont send encap offload frames unencrypted
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit a48daf145fed445d41ef422573411500785415c8 ]
For 802.11 frames, ieee80211_tx_h_select_key() drops a data frame that ended up without a key if the station requires encryption, so that traffic can never leak out unprotected. Encapsulation offload erroneously didn't get this code path. Fix that.
--- net/mac80211/tx.c | 3 +++ 1 file changed, 3 insertions(+)
net/mac80211/tx.c +3 -0
@@ -606,6 +606,9 @@ ieee80211_select_key_8023(struct ieee80211_tx_data *tx) tx->key =rcu_dereference (tx->sta->ptk[tx->sta->ptk_idx]);if (!tx->key) tx->key =rcu_dereference (tx->sdata->default_unicast_key); + +if (!tx->key &&test_sta_flag (tx->sta,WLAN_STA_USES_ENCRYPTION )) +return TX_DROP ; }else if (!ieee80211_vif_is_mld (&tx->sdata->vif)) { tx->key =rcu_dereference (tx->sdata->deflink.default_multicast_key); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2050/3318 wifi: mac80211: drop encap offload frames with a tainted key
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit c8ddbe1e8c43f6d008591c50f8be8de39cdce267 ]
When a key is tainted, which happens in some WoWLAN and extended key ID scenarios, frames that would use it should be dropped. Fix that for encapsulation offload frames.
--- net/mac80211/tx.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
net/mac80211/tx.c +7 -1
@@ -613,7 +613,13 @@ ieee80211_select_key_8023(struct ieee80211_tx_data *tx) tx->key =rcu_dereference (tx->sdata->deflink.default_multicast_key); } -if (tx->key && tx->key->flags &KEY_FLAG_UPLOADED_TO_HARDWARE ) +if (!tx->key) +return TX_CONTINUE ; + +if (unlikely (tx->key->flags &KEY_FLAG_TAINTED )) +return TX_DROP ; + +if (tx->key->flags &KEY_FLAG_UPLOADED_TO_HARDWARE ) info->control.hw_key = &tx->key->conf;return TX_CONTINUE ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2051/3318 wifi: wfx: fix possible device hang during init
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérôme Pouiller <[email protected]>
[ Upstream commit 102f54dc47be198e9310b18d41305a78d70a0796 ]
The WFxxx device provides an SDIO interface. In addition to the usual in-band SDIO IRQ, the device also supports out-of-band IRQ line. OOB IRQ requires a specific initialization described in commit f00dc1d789e1c ("staging: wfx: poll IRQ during init"):
When the chip starts in SDIO mode, the external IRQ (aka Out-Of-Band IRQ) cannot be used before to configure it. Therefore, the first exchanges with the chip have to be done without the OOB IRQ.
This patch allow to poll the data until the OOB IRQ is correctly setup. In order to keep the code simpler, this patch also poll data even if OOB IRQ is not used.
Commit 57aa557f110d9 ("staging: wfx: introduce a way to poll IRQ") announce some limitation about the data polling mechanism:
This function [wfx_bh_poll_irq()] must used with care: if an IRQ fires while the host reads control register, the IRQ can be lost.
However, with last analysis, it seems it does not only impact the IRQ. When this condition happen the hardware is lost and won't reply the next commands. The only way to recover the error is to pull the reset pin and bind the device again.
Currently wfx_bh_poll_irq() is only used during the two first exchanges with the hardware. Therefore, it has been reported to only happen after a few hours of bind/rebind in a loop. This explain why it has not been reported before.
Fortunately, wfx_bh_poll_irq() is only required for OOB IRQ, which is probably very marginal. The In-Band IRQ case also uses this function, but only to simplify the code.
This patch limits the use of wfx_bh_poll_irq() to the OOB IRQ. The bus driver now tells wfx_probe() whether polling is necessary. When it is not (in-band SDIO IRQ and SPI), the IRQ is subscribed before the first exchange with the device and wfx_bh_poll_irq() is never called. When it is (SDIO with OOB IRQ), the behavior is unchanged: the control register is polled until the PDS file has configured the IRQ line.
To conclude, In-Band users are now safe. Users of OOB IRQ will be still impacted by the bug, but there is nothing we can do (and nobody complained during the last 6 years).
--- drivers/net/wireless/silabs/wfx/bh.c | 6 ++-- drivers/net/wireless/silabs/wfx/bus_sdio.c | 1 + drivers/net/wireless/silabs/wfx/main.c | 34 ++++++++++++++-------- 3 files changed, 26 insertions(+), 15 deletions(-)
drivers/net/wireless/silabs/wfx/bh.c +3 -3
@@ -284,10 +284,10 @@ void wfx_bh_request_tx(struct wfx_dev *wdev) }/* If IRQ is not available, this function allow to manually poll the control register and simulate -* an IRQ ahen an event happened. +* an IRQ when an event happened. * -* Note that the device has a bug: If an IRQ raise while host read control register, the IRQ is -* lost. So, use this function carefully (only duing device initialisation). +* Note that the device has a bug: If an IRQ raise while host read control register, the device is +* lost. Unfortunately, this is the only way to initialize the SDIO with out-of-band IRQ. */ void wfx_bh_poll_irq (struct wfx_dev *wdev) {
drivers/net/wireless/silabs/wfx/bus_sdio.c +1 -0
@@ -231,6 +231,7 @@ static int wfx_sdio_probe(struct sdio_func *func, const struct sdio_device_id *i goto sdio_release; } + bus->core->poll_irq = !!bus->of_irq; ret =wfx_probe (bus->core);if (ret) goto sdio_release;
drivers/net/wireless/silabs/wfx/main.c +22 -12
@@ -343,7 +343,6 @@ int wfx_probe(struct wfx_dev *wdev)*/ gpio_saved = wdev->pdata.gpio_wakeup; wdev->pdata.gpio_wakeup =NULL ; - wdev->poll_irq = true; wdev->bh_wq =alloc_workqueue ("wfx_bh_wq" ,WQ_HIGHPRI ,0 );if (!wdev->bh_wq)
@@ -351,16 +350,24 @@ int wfx_probe(struct wfx_dev *wdev)wfx_bh_register (wdev); +if (!wdev->poll_irq) { + err = wdev->hwbus_ops->irq_subscribe (wdev->hwbus_priv); +if (err) + goto bh_unregister; + } + err =wfx_init_device (wdev);if (err) - goto bh_unregister; + goto irq_unsubscribe; + +if (wdev->poll_irq) +wfx_bh_poll_irq (wdev); -wfx_bh_poll_irq (wdev); err =wait_for_completion_timeout (&wdev->firmware_ready,1 *HZ );if (err ==0 ) {dev_err (wdev->dev,"timeout while waiting for startup indication\n" ); err = -ETIMEDOUT ; - goto bh_unregister; + goto irq_unsubscribe; }/* FIXME: fill wiphy::hw_version */
@@ -380,12 +387,12 @@ int wfx_probe(struct wfx_dev *wdev)dev_err (wdev->dev,"unsupported firmware API version (expect 1 while firmware returns %d)\n" , wdev->hw_caps.api_version_major); err = -EOPNOTSUPP ; - goto bh_unregister; + goto irq_unsubscribe; }if (wdev->hw_caps.link_mode ==SEC_LINK_ENFORCED ) {dev_err (wdev->dev,"chip require secure_link, but can't negotiate it\n" ); - goto bh_unregister; + goto irq_unsubscribe; }if (wdev->hw_caps.region_sel_mode) {
@@ -401,12 +408,14 @@ int wfx_probe(struct wfx_dev *wdev)dev_dbg (wdev->dev,"sending configuration file %s\n" , wdev->pdata.file_pds); err =wfx_send_pdata_pds (wdev);if (err <0 && err != -ENOENT ) - goto bh_unregister; + goto irq_unsubscribe; - wdev->poll_irq = false; - err = wdev->hwbus_ops->irq_subscribe (wdev->hwbus_priv); -if (err) - goto bh_unregister; +if (wdev->poll_irq) { + err = wdev->hwbus_ops->irq_subscribe (wdev->hwbus_priv); +if (err) + goto bh_unregister; + wdev->poll_irq = false; + } err =wfx_hif_use_multi_tx_conf (wdev, true);if (err)
@@ -455,7 +464,8 @@ int wfx_probe(struct wfx_dev *wdev) ieee80211_unregister:ieee80211_unregister_hw (wdev->hw); irq_unsubscribe: - wdev->hwbus_ops->irq_unsubscribe (wdev->hwbus_priv); +if (!wdev->poll_irq) + wdev->hwbus_ops->irq_unsubscribe (wdev->hwbus_priv); bh_unregister:wfx_bh_unregister (wdev);destroy_workqueue (wdev->bh_wq);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2052/3318 hwrng: cctrng - Fix runtime PM usage counter leak
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 58d27c41542be6c40edac4f91f35a1dd8bf0d2c2 ]
pm_runtime_get_sync() increments the device usage counter even when runtime resume fails. cctrng_read() propagates errors from cc_trng_pm_get() without scheduling the work that later drops the counter, so a clock or reset-completion failure in cctrng_resume() leaves the counter elevated.
Use pm_runtime_resume_and_get(), which drops the usage counter when resume fails and returns zero on success. This preserves the existing success path while balancing the error path.
This issue was found by a static analysis checker and confirmed by manual source review.
--- drivers/char/hw_random/cctrng.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/char/hw_random/cctrng.c +1 -6
@@ -86,12 +86,7 @@ static inline u32 cc_ioread(struct cctrng_drvdata *drvdata, u32 reg)static int cc_trng_pm_get (struct device *dev) { -int rc =0 ; - - rc =pm_runtime_get_sync (dev); - -/* pm_runtime_get_sync() can return 1 as a valid return code */ -return (rc ==1 ?0 : rc); +return pm_runtime_resume_and_get (dev); }static void cc_trng_pm_put_suspend (struct device *dev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2053/3318 crypto: asymmetric_keys - fix OOB read in pefile_parse_binary
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabrice Derepas <[email protected]>
[ Upstream commit 37d550172c2d3cdb3a5ace3e6cb0625967d86349 ]
pefile_parse_binary() reads the size field of the certificate table's data-directory entry, which sits at fixed index 4 of the PE optional header's data directory:
ctx->certs_size = ddir->certs.size;
but nothing ensures index 4 is present. n_data_dirents (the untrusted NumberOfRvaAndSizes) is only upper-bounded against header_size and may be 0, and header_size need only satisfy cursor < header_size < datalen. A crafted PE with n_data_dirents = 0 and a tiny header_size therefore causes the ddir->certs.size read to land past the end of the image (CWE-125). The chkaddr() that bounds the certificate blob runs only after this read.
verify_pefile_signature() is reached from kexec_file_load() (the lockdown/secure-boot enforced PE-image signature path), and the image is parsed before its signature is checked. The trigger needs CAP_SYS_BOOT and the access is out-of-bounds read only (no write).
Require the certificate table's data-directory entry (index 4) to be present; the existing upper-bound check then keeps ddir->certs within [cursor, header_size).
--- crypto/asymmetric_keys/verify_pefile.c | 5 +++++ 1 file changed, 5 insertions(+)
crypto/asymmetric_keys/verify_pefile.c +5 -0
@@ -87,6 +87,11 @@ static int pefile_parse_binary(const void *pebuf, unsigned int pelen,if (ctx->n_data_dirents > (ctx->header_size - cursor) /sizeof (*dde))return -ELIBBAD ; +/* the certificate table entry must be present in the data directory */ +if (ctx->n_data_dirents <= + offsetof(struct data_directory , certs) /sizeof (*dde)) +return -ELIBBAD ; + ddir = pebuf + cursor; cursor +=sizeof (*dde) * ctx->n_data_dirents;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2054/3318 wifi: mac80211: fix swapped fq_overlimit/fq_overmemory in aqm debugfs
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julius Bairaktaris <[email protected]>
[ Upstream commit 25f3f2ff88ae604a3b473b501fc55d58fcb0f5eb ]
The two scnprintf arguments for fq_overlimit and fq_overmemory are in the wrong order, which results in the aqm debugfs file showing the overmemory count under the fq_overlimit label and vice versa.
--- net/mac80211/debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/debugfs.c +1 -1
@@ -98,8 +98,8 @@ static ssize_t aqm_read(struct file *file,"RW fq_quantum %u\n" , fq->flows_cnt, fq->backlog, - fq->overmemory, fq->overlimit, + fq->overmemory, fq->collisions, fq->memory_usage, fq->memory_limit,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2055/3318 memory: brcmstb_dpfe: validate firmware section sizes
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit e61c1a1103e2617e8f86288368911a8591e35c1e ]
The firmware header is read before the image has been shown to contain a complete header. In addition, the final size check adds two firmware-provided u32 section lengths before comparing the result with fw->size, so the addition can wrap.
Reject images shorter than the fixed header and checksum before reading the header. Then derive the available payload length with subtraction and require the two declared sections to fill it exactly.
--- drivers/memory/brcmstb_dpfe.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/memory/brcmstb_dpfe.c +9 -8
@@ -533,9 +533,15 @@ static int __verify_firmware(struct init_data *init, const struct firmware *fw) {const struct dpfe_firmware_header *header = (void *)fw->data; -unsigned int dmem_size, imem_size, total_size; +unsigned int dmem_size, imem_size;bool is_big_endian = false;const u32 *chksum_ptr; +size_t payload_size; + +if (fw->size <sizeof (*header) +sizeof (*chksum_ptr)) +return ERR_INVALID_SIZE ; + + payload_size = fw->size -sizeof (*header) -sizeof (*chksum_ptr);if (header->magic ==DPFE_BE_MAGIC ) is_big_endian = true;
@@ -554,13 +560,8 @@ static int __verify_firmware(struct init_data *init,if ((dmem_size %sizeof (u32)) !=0 || (imem_size %sizeof (u32)) !=0 )return ERR_INVALID_SIZE ; -/* -* The header + the data section + the instruction section + the -* checksum must be equal to the total firmware size. -*/ - total_size = dmem_size + imem_size +sizeof (*header) + -sizeof (*chksum_ptr); -if (total_size != fw->size) +/* The data and instruction sections must fill the payload exactly. */ +if (dmem_size > payload_size || imem_size != payload_size - dmem_size)return ERR_INVALID_SIZE ;/* The checksum comes at the very end. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2056/3318 regulator: mp886x: fix vsel_mask
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jisheng Zhang <[email protected]>
[ Upstream commit 24fa0eadc2e3c7e9397924197dca7777ec08b8d7 ]
The MP886X vsel is 7bits, fix the vsel_mask.
--- drivers/regulator/mp886x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/mp886x.c +1 -1
@@ -267,7 +267,7 @@ static int mp886x_regulator_register(struct mp886x_device_info *di, rdesc->min_uV =600000 ; rdesc->uV_step =10000 ; rdesc->vsel_reg =MP886X_VSEL ; - rdesc->vsel_mask =0x3f ; + rdesc->vsel_mask =0x7f ; rdesc->ramp_reg =MP886X_SYSCNTLREG1 ; rdesc->ramp_mask =MP886X_SLEW_MASK ; rdesc->ramp_delay_table = di->ci->slew_rates;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2057/3318 efi/cper: Reject CPER records with an out-of-range error_data_length
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit a5a612cd3eecbadf135df1e9b2b40bc9f4c28f1c ]
cper_estatus_check() sizes each section with acpi_hest_get_record_size(), which adds the firmware-controlled u32 error_data_length to the header size as a signed int (see <acpi/ghes.h>). A value in the top sizeof(*gdata) bytes of the u32 range wraps the sum small rather than large, so it slips past the "record_size > data_len" check: against the 72-byte v300 header, 0xffffffb9 sizes the record at 1 and acpi_hest_get_next() walks it a byte at a time, off the end. 0xffffffb8 sizes it at 0 and loops forever.
Use check_add_overflow() to reject a sum that will not fit the int those helpers return, since the walk advances by that value. That subsumes the "acpi_hest_get_size(gdata) > data_len" test above it, because record_size is never smaller than the header.
The later "len < sizeof(*foo)" guards rely on this per-section upper bound; they are lower bounds only.
--- drivers/firmware/efi/cper.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/firmware/efi/cper.c +11 -3
@@ -728,7 +728,7 @@ EXPORT_SYMBOL_GPL(cper_estatus_check_header);int cper_estatus_check (const struct acpi_hest_generic_status *estatus) {struct acpi_hest_generic_data *gdata; -unsigned int data_len, record_size; +unsigned int data_len;int rc; rc =cper_estatus_check_header (estatus);
@@ -738,10 +738,18 @@ int cper_estatus_check(const struct acpi_hest_generic_status *estatus) data_len = estatus->data_length;apei_estatus_for_each_section (estatus, gdata) { -if (acpi_hest_get_size (gdata) > data_len) +int record_size; + +/* +* The <acpi/ghes.h> helpers sum these as a signed int, so a +* huge error_data_length wraps small rather than large and the +* walk then advances by that wrapped value. Reject a size an +* int cannot carry. +*/ +if (check_add_overflow (acpi_hest_get_size (gdata), + gdata->error_data_length, &record_size))return -EINVAL ; - record_size =acpi_hest_get_record_size (gdata);if (record_size > data_len)return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2058/3318 efi/cper: Reject an error status block length that wraps a u32
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 41e25ef5e417c62eb7bf39b187242b283b3ef9f1 ]
cper_estatus_len() sums the firmware-controlled data_length (or raw_data_offset plus raw_data_length) into a u32. A data_length of 0xffffffec wraps that sum to 0, and a length that reads back short defeats every bound built on it: bert_print_all() passes its "remain < estatus_len" check, then advances "estatus += estatus_len" by zero and loops forever. GHES survives only because __ghes_check_estatus() rejects a length below sizeof(*estatus) first.
Reject a length that cannot be expressed in a u32 in cper_estatus_check_header(), which both of today's callers reach: GHES via __ghes_check_estatus() and BERT via cper_estatus_check(). extlog reaches neither yet; a later patch routes it through cper_estatus_check(), whose ELOG_ENTRY_LEN bound needs this to hold.
--- drivers/firmware/efi/cper.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/firmware/efi/cper.c +11 -0
@@ -721,6 +721,17 @@ int cper_estatus_check_header(const struct acpi_hest_generic_status *estatus) estatus->raw_data_offset < sizeof(*estatus) + estatus->data_length) return -EINVAL; +/* +* cper_estatus_len() sums these into a u32, and a wrapped sum reads +* back smaller than the record. Reject a length that cannot be +* expressed so no caller is handed the short value. +*/ +if ((u64 )sizeof (*estatus) + estatus->data_length >U32_MAX ) +return -EINVAL ; +if (estatus->raw_data_length && + (u64 )estatus->raw_data_offset + estatus->raw_data_length >U32_MAX ) +return -EINVAL ; +return 0 ; }EXPORT_SYMBOL_GPL (cper_estatus_check_header);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2059/3318 ACPI: extlog: Validate elog record length before walking sections
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit e1fd582a8134150aa10c1f0286dbce00cf63b086 ]
extlog_print() copies a fixed ELOG_ENTRY_LEN (4096) bytes from the elog record into elog_buf, then walks the sections using the firmware-controlled data_length. Nothing keeps data_length inside the buffer, so a malformed record walks the section pointer past elog_buf and reads adjacent memory. Unlike the GHES paths, extlog never calls cper_estatus_check().
Reject a record longer than ELOG_ENTRY_LEN and run cper_estatus_check() before walking the sections. The length test alone is not enough: a wrapped length reads back short and passes it, which cper_estatus_check() catches via the header check added earlier. Drop a malformed record with NOTIFY_DONE and without MCE_HANDLED_EXTLOG, since extlog did not consume it.
--- drivers/acpi/acpi_extlog.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/acpi/acpi_extlog.c +9 -0
@@ -159,6 +159,15 @@ static int extlog_print(struct notifier_block *nb, unsigned long val, tmp = (struct acpi_hest_generic_status *)elog_buf; +/* +* Bound the length before cper_estatus_check() walks the sections: it +* iterates over data_length, which is not yet known to fit elog_buf. +* cper_estatus_check_header() then rejects a length that wrapped, which +* the bound cannot see. +*/ +if (cper_estatus_len (tmp) >ELOG_ENTRY_LEN ||cper_estatus_check (tmp)) +return NOTIFY_DONE ; +if (!ras_userspace_consumers ()) {print_extlog_rcd (NULL , tmp, cpu); goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2060/3318 efi/cper: Read only validated fields in cper_mem_err_pack()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 92480a2b00a15b0add512b6fc474151ec5340a8e ]
cper_mem_err_pack() copies extended, rank, mem_array_handle and mem_dev_handle unconditionally. Those live at offsets 73 to 79, past the end of struct cper_sec_mem_err_old, the 73-byte UEFI 2.1/2.2 layout that older firmware still emits and that cper_estatus_print_section() admits. On such a record the copy reads up to seven bytes past the payload, and off the end of the error status block when that section is the last one.
Copy each of the four only when its validation bit is set, and zero it otherwise. Nothing is lost: a 2.1/2.2 record leaves those bits clear, and every consumer of struct cper_mem_err_compact already gates the fields on the same bits. Zeroing also stops callers reading them back out of the uninitialised on-stack struct they pass in.
--- drivers/firmware/efi/cper.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-)
drivers/firmware/efi/cper.c +22 -4
@@ -389,10 +389,28 @@ void cper_mem_err_pack(const struct cper_sec_mem_err *mem, cmem->requestor_id = mem->requestor_id; cmem->responder_id = mem->responder_id; cmem->target_id = mem->target_id; - cmem->extended = mem->extended; - cmem->rank = mem->rank; - cmem->mem_array_handle = mem->mem_array_handle; - cmem->mem_dev_handle = mem->mem_dev_handle; + +/* +* These four sit past the end of the UEFI 2.1/2.2 layout, which older +* firmware still emits, so reading them unconditionally runs off a +* short record. Every consumer of the compact record gates them on the +* same validation bits, so leave them zero when firmware does not +* claim them. +*/ + cmem->extended =0 ; + cmem->rank =0 ; + cmem->mem_array_handle =0 ; + cmem->mem_dev_handle =0 ; + +if (mem->validation_bits & + (CPER_MEM_VALID_ROW_EXT |CPER_MEM_VALID_CHIP_ID )) + cmem->extended = mem->extended; +if (mem->validation_bits &CPER_MEM_VALID_RANK_NUMBER ) + cmem->rank = mem->rank; +if (mem->validation_bits &CPER_MEM_VALID_CARD_HANDLE ) + cmem->mem_array_handle = mem->mem_array_handle; +if (mem->validation_bits &CPER_MEM_VALID_MODULE_HANDLE ) + cmem->mem_dev_handle = mem->mem_dev_handle; }EXPORT_SYMBOL_GPL (cper_mem_err_pack);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2061/3318 spi: mtk-nor: fix runtime PM usage count leak in probe error path
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Gu <[email protected]>
[ Upstream commit 4cee1ed13e2687f1a9fec7dd50e31eb179506d75 ]
mtk_nor_probe() takes a runtime PM reference with pm_runtime_get_noresume() before registering the controller, but the error path never drops it.
Balance the get with pm_runtime_put_noidle() in the error path.
--- drivers/spi/spi-mtk-nor.c | 1 + 1 file changed, 1 insertion(+)
drivers/spi/spi-mtk-nor.c +1 -0
@@ -926,6 +926,7 @@ static int mtk_nor_probe(struct platform_device *pdev)return 0 ; err_probe: +pm_runtime_put_noidle (&pdev->dev);pm_runtime_disable (&pdev->dev);pm_runtime_set_suspended (&pdev->dev);pm_runtime_dont_use_autosuspend (&pdev->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2062/3318 remoteproc: imx_rproc: Allow mappings ending at region boundary
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marcel Hofmann <[email protected]>
[ Upstream commit 749eed0c7178c8d53ce4c9acdda4a545721c494b ]
The address range checks in imx_rproc_da_to_sys() and imx_rproc_da_to_va() use a strict comparison for the exclusive end address of the requested range.
As a result, a valid request that ends exactly at the end of an address translation or mapped memory region is rejected. For a region [start, start + size), a request [addr, addr + len) is contained when:
addr >= start && addr + len <= start + size
This occurs when a loadable ELF segment fills an entire mapped memory region. This can be produced by a linker script that extends the resource table section to the end of its designated region:
.resource_table :
{
. = ALIGN(8);
KEEP(*(.resource_table)) /* Resource table */
. = ALIGN(8);
. = ORIGIN(m_rsc_tbl) + LENGTH(m_rsc_tbl);
} > m_rsc_tbl =0x00This produces a ELF program header like:
LOAD 0x010000 0xa4220000 0xa4220000 0x01000 0x01000 R 0x1000
In this case, the segment size matches the mapped region size exactly, causing the address translation to fail with:
bad phdr da 0xa4220000 mem 0x1000
Rework the upper-bound checks to allow ranges ending exactly at the region boundary while guarding against integer overflow.
--- drivers/remoteproc/imx_rproc.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/remoteproc/imx_rproc.c +13 -5
@@ -463,6 +463,7 @@ static int imx_rproc_da_to_sys(struct imx_rproc *priv, u64 da,/* parse address translation table */ for (i =0 ; i < dcfg->att_size; i++) {const struct imx_rproc_att *att = &dcfg->att[i]; +u64 offset;/* * Ignore entries not belong to current core:
@@ -475,9 +476,11 @@ static int imx_rproc_da_to_sys(struct imx_rproc *priv, u64 da,continue ; } -if (da >= att->da && da + len < att->da + att->size) { -unsigned int offset = da - att->da; +if (da < att->da) +continue ; + offset = da - att->da; +if (offset <= att->size && len <= att->size - offset) { *sys = att->sa + offset;if (is_iomem) *is_iomem = att->flags &ATT_IOMEM ;
@@ -508,9 +511,14 @@ static void *imx_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *ireturn NULL ;for (i =0 ; i <IMX_RPROC_MEM_MAX ; i++) { -if (sys >= priv->mem[i].sys_addr && sys + len < - priv->mem[i].sys_addr + priv->mem[i].size) { -unsigned int offset = sys - priv->mem[i].sys_addr; +u64 offset; + +if (sys < priv->mem[i].sys_addr) +continue ; + + offset = sys - priv->mem[i].sys_addr; +if (offset <= priv->mem[i].size && + len <= priv->mem[i].size - offset) {/* __force to make sparse happy with type conversion */ va = (__force void *)(priv->mem[i].cpu_addr + offset);break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2063/3318 perf evsel: Validate branch stack before byte swapping
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Amirkan <[email protected]>
[ Upstream commit 2148e094671b0f6a44f033787b7da4ed14e96c27 ]
When perf reads an opposite-endian branch stack, __evsel__parse_sample() swaps each entry before checking whether all entries fit in the event. A truncated sample can therefore make the swap loop read and write past the event boundary.
A truncated perf.data file makes perf report crash with SIGSEGV. ASan reports an out-of-bounds read. A regression test puts an entry just past the declared end and shows that its flags are changed before the parser returns -EFAULT.
Move the bounds check before the byte-swap loop. Valid samples are handled as before.
--- tools/perf/tests/sample-parsing.c | 48 +++++++++++++++++++++++++++++++ tools/perf/util/evsel.c | 3 +- 2 files changed, 50 insertions(+), 1 deletion(-)
tools/perf/tests/sample-parsing.c +48 -0
@@ -1,5 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include <stdbool.h> +#include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h>
@@ -366,6 +367,49 @@ static int do_test(u64 sample_type, u64 sample_regs, u64 read_format)return ret; } +static int test_truncated_branch_stack (void ) +{ +struct perf_event_attr attr = { + .sample_type =PERF_SAMPLE_BRANCH_STACK , + }; +struct { +struct perf_event_header header; +u64 nr; +struct branch_entry entry; + } input = { + .header = { + .type =PERF_RECORD_SAMPLE , + .size =sizeof (input.header) +sizeof (input.nr), + }, + .nr =1 , + }; +struct perf_sample sample; +struct evsel *evsel; +u64 flags =1 ; +int err; + + input.entry.flags.value = flags; + evsel =evsel__new (&attr); +if (!evsel) +return -1 ; + + evsel->sample_size =__evsel__sample_size (attr.sample_type); + err =__evsel__parse_sample (evsel, (union perf_event *)&input, + &sample,/*needs_swap=*/ true); +perf_sample__exit (&sample); +evsel__put (evsel); + +if (err != -EFAULT ) { +pr_debug ("truncated branch stack returned %d, expected -EFAULT\n" , err); +return -1 ; + } +if (input.entry.flags.value != flags) { +pr_debug ("truncated branch stack modified data past the event\n" ); +return -1 ; + } +return 0 ; +} +/** * test__sample_parsing - test sample parsing. *
@@ -382,6 +426,10 @@ static int test__sample_parsing(struct test_suite *test __maybe_unused, int subtsize_t i;int err; + err =test_truncated_branch_stack (); +if (err) +return err; +/* * Fail the test if it has not been updated when new sample format bits * were added. Please actually update the test rather than just change
tools/perf/util/evsel.c +2 -1
@@ -2570,6 +2570,8 @@ int evsel__parse_sample(struct evsel *evsel, union perf_event *event, e = (struct branch_entry *)&data->branch_stack->hw_idx; } +OVERFLOW_CHECK (array, sz, max_size); +if (swapped) {/* * struct branch_flag does not have endian
@@ -2585,7 +2587,6 @@ int evsel__parse_sample(struct evsel *evsel, union perf_event *event, e->flags.value =evsel__bitfield_swap_branch_flags (e->flags.value); } -OVERFLOW_CHECK (array, sz, max_size); array = (void *)array + sz; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2064/3318 perf evsel: Validate RAW sample before byte swapping
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Amirkan <[email protected]>
[ Upstream commit 02f6847e1822714a4201b87e42f92b0d43e8549d ]
For an opposite-endian RAW sample, __evsel__parse_sample() passes the input-controlled size to mem_bswap_64() before checking whether the payload fits in the event. A truncated record can therefore make the helper read and write past the event boundary.
A crafted perf.data file makes perf report crash with SIGSEGV. ASan reports the out-of-bounds access. A regression test puts backed data past the declared end and shows that it is changed before the parser returns -EFAULT.
Move the bounds checks before mem_bswap_64(). Check the rounded length too, because the helper accesses complete 64-bit words. Complete records are handled as before.
--- tools/perf/tests/sample-parsing.c | 61 +++++++++++++++++++++++++++++++ tools/perf/util/evsel.c | 17 +++++---- 2 files changed, 70 insertions(+), 8 deletions(-)
tools/perf/tests/sample-parsing.c +61 -0
@@ -410,6 +410,55 @@ static int test_truncated_branch_stack(void)return 0 ; } +static int test_truncated_swapped_raw (u16 event_size,u32 raw_size) +{ +struct perf_event_attr attr = { + .sample_type =PERF_SAMPLE_RAW , + }; +struct { +struct perf_event_header header; +union { +u64 value; +u32 words[2 ]; + } raw; +u64 canary; + } input = { + .header = { + .type =PERF_RECORD_SAMPLE , + .size = event_size, + }, +/* Parsing a pre-swapped word exchanges these two u32 values. */ + .raw.words = {0x12345678 , raw_size }, + .canary =0x8877665544332211ULL , + }; +struct perf_sample sample; +struct evsel *evsel; +u64 raw = input.raw.value; +u64 canary = input.canary; +int err; + + evsel =evsel__new (&attr); +if (!evsel) +return -1 ; + + evsel->sample_size =__evsel__sample_size (attr.sample_type); + err =__evsel__parse_sample (evsel, (union perf_event *)&input, + &sample,/*needs_swap=*/ true); +perf_sample__exit (&sample); +evsel__put (evsel); + +if (err != -EFAULT ) { +pr_debug ("truncated swapped RAW sample (size %u, raw %u) returned %d, expected -EFAULT\n" , + event_size, raw_size, err); +return -1 ; + } +if (input.raw.value != raw || input.canary != canary) { +pr_debug ("truncated swapped RAW sample modified data before validation\n" ); +return -1 ; + } +return 0 ; +} +/** * test__sample_parsing - test sample parsing. *
@@ -430,6 +479,18 @@ static int test__sample_parsing(struct test_suite *test __maybe_unused, int subtif (err)return err; +/* The declared RAW payload extends past an otherwise aligned event. */ + err =test_truncated_swapped_raw (sizeof (struct perf_event_header ) + +sizeof (u64),16 ); +if (err) +return err; + +/* The final complete word touched by mem_bswap_64() extends past it. */ + err =test_truncated_swapped_raw (sizeof (struct perf_event_header ) + +sizeof (u32) +9 ,9 ); +if (err) +return err; +/* * Fail the test if it has not been updated when new sample format bits * were added. Please actually update the test rather than just change
tools/perf/util/evsel.c +9 -8
@@ -2515,7 +2515,10 @@ int evsel__parse_sample(struct evsel *evsel, union perf_event *event, }if (type &PERF_SAMPLE_RAW ) { +const __u64 *raw; +OVERFLOW_CHECK_u64 (array); + raw = array; u.val64 = *array;/*
@@ -2531,16 +2534,14 @@ int evsel__parse_sample(struct evsel *evsel, union perf_event *event, } data->raw_size = u.val32[0 ]; -/* -* The raw data is aligned on 64bits including the -* u32 size, so it's safe to use mem_bswap_64. -*/ -if (swapped) -mem_bswap_64 ((void *) array, data->raw_size); - array = (void *)array +sizeof (u32); -OVERFLOW_CHECK (array, data->raw_size, max_size); +if (swapped) { +/* mem_bswap_64() accesses complete 64-bit words. */ + sz =roundup ((u64 )data->raw_size,sizeof (u64)); +OVERFLOW_CHECK (raw, sz, max_size); +mem_bswap_64 ((void *)raw, data->raw_size); + } data->raw_data = (void *)array; array = (void *)array + data->raw_size; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2065/3318 RDMA/irdma: Preserve fast-registration IOVA on 32-bit
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit c470050f2a7a7748ce35367e828885a8e658d712 ]
ib_mr::iova is u64, but the fast-registration path passes it through void * and uintptr_t. These conversions truncate the upper 32 bits on 32-bit kernels before the WQE is built.
Store the IOVA as u64 and write it directly to the WQE. The sole caller always uses VA-based addressing, so remove the unused FBO selection and set the VA-based bit unconditionally.
--- drivers/infiniband/hw/irdma/ctrl.c | 6 ++---- drivers/infiniband/hw/irdma/type.h | 4 +--- drivers/infiniband/hw/irdma/verbs.c | 3 +-- 3 files changed, 4 insertions(+), 9 deletions(-)
drivers/infiniband/hw/irdma/ctrl.c +2 -4
@@ -1320,9 +1320,7 @@ int irdma_sc_mr_fast_register(struct irdma_sc_qp *qp, info->wr_id, wqe_idx, &qp->qp_uk.sq_wrtrk_array[wqe_idx].wrid); - temp = (info->addr_type ==IRDMA_ADDR_TYPE_VA_BASED ) ? - (uintptr_t )info->va : info->fbo; -set_64bit_val (wqe,0 , temp); +set_64bit_val (wqe,0 , info->va); temp =FIELD_GET (IRDMAQPSQ_FIRSTPMPBLIDXHI , info->first_pm_pbl_index >>16 );
@@ -1339,7 +1337,7 @@ int irdma_sc_mr_fast_register(struct irdma_sc_qp *qp,FIELD_PREP (IRDMAQPSQ_LPBLSIZE , info->chunk_size) |FIELD_PREP (IRDMAQPSQ_HPAGESIZE , page_size) |FIELD_PREP (IRDMAQPSQ_STAGRIGHTS , info->access_rights) | -FIELD_PREP (IRDMAQPSQ_VABASEDTO , info->addr_type) | +IRDMAQPSQ_VABASEDTO |FIELD_PREP (IRDMAQPSQ_READFENCE , info->read_fence) |FIELD_PREP (IRDMAQPSQ_LOCALFENCE , info->local_fence) | FIELD_PREP(IRDMAQPSQ_SIGCOMPL, info->signaled) |
drivers/infiniband/hw/irdma/type.h +1 -3
@@ -1005,13 +1005,11 @@ struct irdma_reg_ns_stag_info {struct irdma_fast_reg_stag_info {u64 wr_id;u64 reg_addr_pa; -u64 fbo; -void *va; +u64 va;u64 total_len;u32 page_size;u32 chunk_size;u32 first_pm_pbl_index; -enum irdma_addressing_type addr_type;irdma_stag_index stag_idx;u16 access_rights;u32 pd_id;
drivers/infiniband/hw/irdma/verbs.c +1 -2
@@ -3564,8 +3564,7 @@ static int irdma_post_send(struct ib_qp *ibqp, stag_info.stag_idx =reg_wr (ib_wr)->key >>8 ; stag_info.page_size =reg_wr (ib_wr)->mr->page_size; stag_info.wr_id = ib_wr->wr_id; - stag_info.addr_type =IRDMA_ADDR_TYPE_VA_BASED ; - stag_info.va = (void *)(uintptr_t )iwmr->ibmr.iova; + stag_info.va = iwmr->ibmr.iova; stag_info.total_len = iwmr->ibmr.length; stag_info.reg_addr_pa = *palloc->level1.addr; stag_info.first_pm_pbl_index = palloc->level1.idx;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2066/3318 gpio: crystalcove: add missing MODULE_ALIAS()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Torokhov <[email protected]>
[ Upstream commit 32c7f7f80e5f7f2764682fd456054478fc11c8d9 ]
The crystalcove GPIO driver lacks a MODULE_ALIAS() to allow it to be auto-loaded.
Fix this by adding the missing platform alias.
--- drivers/gpio/gpio-crystalcove.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpio/gpio-crystalcove.c +1 -0
@@ -395,3 +395,4 @@ module_platform_driver(crystalcove_gpio_driver);MODULE_AUTHOR ("Yang, Bin <[email protected]>" );MODULE_DESCRIPTION ("Intel Crystal Cove GPIO Driver" );MODULE_LICENSE ("GPL v2" ); +MODULE_ALIAS ("platform:crystal_cove_gpio" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2067/3318 drivers/base/node: fix UAF on device_register() failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linkai Gong <[email protected]>
[ Upstream commit 6d7e9bc51d8f2d73b3403c759c769f880082f9ae ]
node_init_node_access() frees the access node with kfree() if device_register() fails. After device_register() the embedded device is initialized and must be released with put_device() so that node_access_release() can free it.
--- drivers/base/node.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/base/node.c +8 -9
@@ -144,20 +144,19 @@ static struct node_access_nodes *node_init_node_access(struct node *node, dev->parent = &node->dev; dev->release = node_access_release; dev->groups = node_access_node_groups; -if (dev_set_name (dev,"access%u" , access)) - goto free; +if (dev_set_name (dev,"access%u" , access)) { +kfree (access_node); +return NULL ; + } -if (device_register (dev)) - goto free_name; +if (device_register (dev)) { +put_device (dev); +return NULL ; + }pm_runtime_no_callbacks (dev);list_add_tail (&access_node->list_node, &node->access_list);return access_node; -free_name: -kfree_const (dev->kobj.name); -free: -kfree (access_node); -return NULL ; }#ifdef CONFIG_HMEM_REPORTING
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2068/3318 irqchip/gic-v3-its: Dont WARN on LPI free allocation failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 135d9e67f7ab4f261c2157ee2de1f93a4de39a41 ]
free_lpi_range() cannot give LPIs back to the allocator without allocating a struct lpi_range to describe the freed range, so it returns -ENOMEM (its only failure mode) when that allocation fails, and its_lpi_free() turns this into a WARN_ON().
syzbot triggers the WARN_ON() by injecting a slab allocation failure on device teardown, which with panic_on_warn becomes a panic:
WARNING: drivers/irqchip/irq-gic-v3-its.c:2251 at its_msi_teardown+0x3a4/0x424 its_msi_teardown+0x3a4/0x424 msi_remove_device_irq_domain+0x16c/0x27c msi_device_data_release+0x38/0x9c
The failure is transient and the consequence benign: the freed range is simply never returned to the allocator. This does not warrant a WARN_ON() backtrace, so log a rate-limited error instead.
--- drivers/irqchip/irq-gic-v3-its.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3-its.c +2 -1
@@ -2175,7 +2175,8 @@ static unsigned long *its_lpi_alloc(int nr_irqs, u32 *base, int *nr_ids)static void its_lpi_free (unsigned long *bitmap,u32 base,u32 nr_ids) { -WARN_ON (free_lpi_range (base, nr_ids)); +if (free_lpi_range (base, nr_ids)) +pr_err_ratelimited ("ITS: failed to free LPI range %u:%u\n" , base, nr_ids);bitmap_free (bitmap); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2069/3318 ASoC: codecs: ES8326: Changing initialisation and broadcasting
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhu Ning <[email protected]>
[ Upstream commit fc702b2c04d778d7e3a4091ebe54a86c5d0a0d96 ]
New chip versions require new initialisation and playback processes. Changing the initialisation and playback process for better results. The old chip versions are going to work well with the new sequences. We've tested this with version_v0 and version_v3 chips under the new sequence and they both pass.
Stable-dep-of: 349e94679968 ("ASoC: es8326: report resume restore errors")
--- sound/soc/codecs/es8326.c | 50 +++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 21 deletions(-)
sound/soc/codecs/es8326.c +29 -21
@@ -132,6 +132,11 @@ static const struct snd_soc_dapm_widget es8326_dapm_widgets[] = {SND_SOC_DAPM_PGA ("LHPMIX" ,ES8326_DAC2HPMIX ,7 ,0 ,NULL ,0 ),SND_SOC_DAPM_PGA ("RHPMIX" ,ES8326_DAC2HPMIX ,3 ,0 ,NULL ,0 ), +SND_SOC_DAPM_REG (snd_soc_dapm_supply,"HPOR Supply" ,ES8326_HP_CAL , +4 ,7 ,0 ,0 ), +SND_SOC_DAPM_REG (snd_soc_dapm_supply,"HPOL Supply" ,ES8326_HP_CAL , +0 ,7 ,0 ,0 ), +SND_SOC_DAPM_OUTPUT ("HPOL" ), SND_SOC_DAPM_OUTPUT("HPOR"), };
@@ -156,6 +161,9 @@ static const struct snd_soc_dapm_route es8326_dapm_routes[] = { {"LHPMIX", NULL, "Left DAC"}, {"RHPMIX", NULL, "Right DAC"}, + {"HPOR", NULL, "HPOR Supply"}, + {"HPOL", NULL, "HPOL Supply"}, + {"HPOL", NULL, "LHPMIX"}, {"HPOR", NULL, "RHPMIX"}, };
@@ -409,8 +417,8 @@ static int es8326_mute(struct snd_soc_dai *dai, int mute, int direction)regmap_write (es8326->regmap,ES8326_HPR_OFFSET_INI , offset_r); es8326->calibrated = true; } -regmap_write (es8326->regmap,ES8326_HP_DRIVER ,0xa0 ); -regmap_write (es8326->regmap,ES8326_HP_VOL ,0x80 ); +regmap_write (es8326->regmap,ES8326_HP_DRIVER ,0xa1 ); +regmap_write (es8326->regmap,ES8326_HP_VOL ,0x91 );regmap_write (es8326->regmap,ES8326_HP_CAL ,ES8326_HP_ON );regmap_update_bits (es8326->regmap,ES8326_DAC_MUTE ,ES8326_MUTE_MASK , ~(ES8326_MUTE ));
@@ -430,8 +438,6 @@ static int es8326_set_bias_level(struct snd_soc_component *codec,if (ret)return ret; -regmap_write (es8326->regmap,ES8326_RESET ,0x9f ); -msleep (20 );regmap_update_bits (es8326->regmap,ES8326_DAC_DSM ,0x01 ,0x00 );regmap_write (es8326->regmap,ES8326_INTOUT_IO , es8326->interrupt_clk); regmap_write(es8326->regmap, ES8326_SDINOUT1_IO,
@@ -440,19 +446,21 @@ static int es8326_set_bias_level(struct snd_soc_component *codec,regmap_write (es8326->regmap,ES8326_PGA_PDN ,0x40 );regmap_write (es8326->regmap,ES8326_ANA_PDN ,0x00 );regmap_update_bits (es8326->regmap,ES8326_CLK_CTL ,0x20 ,0x20 ); -regmap_write (es8326->regmap,ES8326_RESET ,ES8326_CSM_ON ); + +regmap_update_bits (es8326->regmap,ES8326_RESET , +ES8326_CSM_ON ,ES8326_CSM_ON );break ;case SND_SOC_BIAS_PREPARE :break ;case SND_SOC_BIAS_STANDBY : -break ; -case SND_SOC_BIAS_OFF : -clk_disable_unprepare (es8326->mclk);regmap_write (es8326->regmap,ES8326_ANA_PDN ,0x3b );regmap_write (es8326->regmap,ES8326_VMIDSEL ,0x00 );regmap_update_bits (es8326->regmap,ES8326_CLK_CTL ,0x20 ,0x00 );regmap_write (es8326->regmap,ES8326_SDINOUT1_IO ,ES8326_IO_INPUT );break ; +case SND_SOC_BIAS_OFF : +clk_disable_unprepare (es8326->mclk); +break ; }return 0 ;
@@ -724,13 +732,15 @@ static int es8326_calibrate(struct snd_soc_component *component)regmap_write (es8326->regmap,ES8326_CLK_DIV1 ,0x01 );regmap_write (es8326->regmap,ES8326_CLK_DLL ,0x30 );regmap_write (es8326->regmap,ES8326_CLK_MUX ,0xed ); +regmap_write (es8326->regmap,ES8326_CLK_DAC_SEL ,0x08 );regmap_write (es8326->regmap,ES8326_CLK_TRI ,0xc1 );regmap_write (es8326->regmap,ES8326_DAC_MUTE ,0x03 );regmap_write (es8326->regmap,ES8326_ANA_VSEL ,0x7f ); -regmap_write (es8326->regmap,ES8326_VMIDLOW ,0x33 ); +regmap_write (es8326->regmap,ES8326_VMIDLOW ,0x03 );regmap_write (es8326->regmap,ES8326_DAC2HPMIX ,0x88 ); -regmap_write (es8326->regmap,ES8326_HP_VOL ,0x80 ); +usleep_range (15000 ,20000 );regmap_write (es8326->regmap,ES8326_HP_OFFSET_CAL ,0x8c ); +usleep_range (15000 ,20000 );regmap_write (es8326->regmap,ES8326_RESET ,0xc0 );usleep_range (15000 ,20000 );
@@ -768,27 +778,27 @@ static int es8326_resume(struct snd_soc_component *component)regmap_write (es8326->regmap,ES8326_RESET ,0x1f );regmap_write (es8326->regmap,ES8326_VMIDSEL ,0x0E );usleep_range (10000 ,15000 ); -regmap_write (es8326->regmap,ES8326_HPJACK_TIMER ,0x88 ); +regmap_write (es8326->regmap,ES8326_HPJACK_TIMER ,0xe9 ); +regmap_write (es8326->regmap,ES8326_ANA_MICBIAS ,0x4b );/* set headphone default type and detect pin */ -regmap_write (es8326->regmap,ES8326_HPDET_TYPE ,0x81 ); +regmap_write (es8326->regmap,ES8326_HPDET_TYPE ,0x83 );regmap_write (es8326->regmap,ES8326_CLK_RESAMPLE ,0x05 ); +regmap_write (es8326->regmap,ES8326_HP_MISC ,0x30 );/* set internal oscillator as clock source of headpone cp */ -regmap_write (es8326->regmap,ES8326_CLK_DIV_CPC ,0x84 ); +regmap_write (es8326->regmap,ES8326_CLK_DIV_CPC ,0x89 );regmap_write (es8326->regmap,ES8326_CLK_CTL ,ES8326_CLK_ON );/* clock manager reset release */ regmap_write (es8326->regmap,ES8326_RESET ,0x17 );/* set headphone detection as half scan mode */ -regmap_write (es8326->regmap,ES8326_HP_MISC ,0x08 ); +regmap_write (es8326->regmap,ES8326_HP_MISC ,0x30 );regmap_write (es8326->regmap,ES8326_PULLUP_CTL ,0x00 );/* enable headphone driver */ regmap_write (es8326->regmap,ES8326_HP_DRIVER ,0xa7 );usleep_range (2000 ,5000 ); -regmap_write (es8326->regmap,ES8326_HP_DRIVER_REF ,0xab ); -usleep_range (2000 ,5000 ); -regmap_write (es8326->regmap,ES8326_HP_DRIVER_REF ,0xbb ); -usleep_range (2000 ,5000 ); +regmap_write (es8326->regmap,ES8326_HP_DRIVER_REF ,0xa3 ); +regmap_write (es8326->regmap,ES8326_HP_DRIVER_REF ,0xb3 );regmap_write (es8326->regmap,ES8326_HP_DRIVER ,0xa1 );regmap_write (es8326->regmap,ES8326_CLK_INV ,0x00 );
@@ -802,9 +812,6 @@ static int es8326_resume(struct snd_soc_component *component)/* set ADC and DAC in low power mode */ regmap_write (es8326->regmap,ES8326_ANA_LP ,0xf0 ); -/* force micbias on */ -regmap_write (es8326->regmap,ES8326_ANA_MICBIAS ,0x4f ); -regmap_write (es8326->regmap,ES8326_SYS_BIAS ,0x08 );regmap_write (es8326->regmap,ES8326_ANA_VSEL ,0x7F );/* select vdda as micbias source */ regmap_write (es8326->regmap,ES8326_VMIDLOW ,0x23 );
@@ -832,6 +839,7 @@ static int es8326_resume(struct snd_soc_component *component) ((es8326->version ==ES8326_VERSION_B ) ? (ES8326_HP_DET_SRC_PIN9 | es8326->jack_pol) : (ES8326_HP_DET_SRC_PIN9 | es8326->jack_pol | 0x04))); +regmap_write (es8326->regmap,ES8326_HP_VOL ,0x11 ); es8326->jack_remove_retry =0 ; es8326->hp =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2070/3318 ASoC: codecs: ES8326: Improving the THD+N performance
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhu Ning <[email protected]>
[ Upstream commit 14a0a1ec3335ac3945a96437c35465e4a9616b88 ]
We update the values of some registers in the initialization sequence in es8326_resume function to improve THD+N performance. THD+N performance decreases if the output level on headphone is close to full scale. So we change the register setting in es8326_jack_detect_handler function to improve THD+N performance if headphone pulgged. Also, the register setting should be restored when the headset is unplugged
Stable-dep-of: 349e94679968 ("ASoC: es8326: report resume restore errors")
--- sound/soc/codecs/es8326.c | 21 +++++++++++++-------- sound/soc/codecs/es8326.h | 2 +- 2 files changed, 14 insertions(+), 9 deletions(-)
sound/soc/codecs/es8326.c +13 -8
@@ -635,6 +635,8 @@ static void es8326_jack_detect_handler(struct work_struct *work) es8326->hp =0 ; }regmap_update_bits (es8326->regmap,ES8326_HPDET_TYPE ,0x03 ,0x01 ); +regmap_write (es8326->regmap,ES8326_SYS_BIAS ,0x0a ); +regmap_update_bits (es8326->regmap,ES8326_HP_DRIVER_REF ,0x0f ,0x03 );/* * Inverted HPJACK_POL bit to trigger one IRQ to double check HP Removal event */
@@ -660,6 +662,8 @@ static void es8326_jack_detect_handler(struct work_struct *work)regmap_update_bits (es8326->regmap,ES8326_HPDET_TYPE ,0x03 ,0x01 );usleep_range (50000 ,70000 );regmap_update_bits (es8326->regmap,ES8326_HPDET_TYPE ,0x03 ,0x00 ); +regmap_write (es8326->regmap,ES8326_SYS_BIAS ,0x1f ); +regmap_update_bits (es8326->regmap,ES8326_HP_DRIVER_REF ,0x0f ,0x08 );queue_delayed_work (system_wq, &es8326->jack_detect_work,msecs_to_jiffies (100 )); es8326->hp =1 ;
@@ -729,14 +733,14 @@ static int es8326_calibrate(struct snd_soc_component *component)if ((es8326->version ==ES8326_VERSION_B ) && (es8326->calibrated == false)) {dev_dbg (component->dev,"ES8326_VERSION_B, calibrating\n" );regmap_write (es8326->regmap,ES8326_CLK_INV ,0xc0 ); -regmap_write (es8326->regmap,ES8326_CLK_DIV1 ,0x01 ); +regmap_write (es8326->regmap,ES8326_CLK_DIV1 ,0x03 );regmap_write (es8326->regmap,ES8326_CLK_DLL ,0x30 );regmap_write (es8326->regmap,ES8326_CLK_MUX ,0xed );regmap_write (es8326->regmap,ES8326_CLK_DAC_SEL ,0x08 );regmap_write (es8326->regmap,ES8326_CLK_TRI ,0xc1 );regmap_write (es8326->regmap,ES8326_DAC_MUTE ,0x03 );regmap_write (es8326->regmap,ES8326_ANA_VSEL ,0x7f ); -regmap_write (es8326->regmap,ES8326_VMIDLOW ,0x03 ); +regmap_write (es8326->regmap,ES8326_VMIDLOW ,0x23 );regmap_write (es8326->regmap,ES8326_DAC2HPMIX ,0x88 );usleep_range (15000 ,20000 );regmap_write (es8326->regmap,ES8326_HP_OFFSET_CAL ,0x8c );
@@ -777,13 +781,13 @@ static int es8326_resume(struct snd_soc_component *component)/* reset internal clock state */ regmap_write (es8326->regmap,ES8326_RESET ,0x1f );regmap_write (es8326->regmap,ES8326_VMIDSEL ,0x0E ); +regmap_write (es8326->regmap,ES8326_ANA_LP ,0xf0 );usleep_range (10000 ,15000 );regmap_write (es8326->regmap,ES8326_HPJACK_TIMER ,0xe9 ); -regmap_write (es8326->regmap,ES8326_ANA_MICBIAS ,0x4b ); +regmap_write (es8326->regmap,ES8326_ANA_MICBIAS ,0xcb );/* set headphone default type and detect pin */ regmap_write (es8326->regmap,ES8326_HPDET_TYPE ,0x83 );regmap_write (es8326->regmap,ES8326_CLK_RESAMPLE ,0x05 ); -regmap_write (es8326->regmap,ES8326_HP_MISC ,0x30 );/* set internal oscillator as clock source of headpone cp */ regmap_write (es8326->regmap,ES8326_CLK_DIV_CPC ,0x89 );
@@ -791,14 +795,15 @@ static int es8326_resume(struct snd_soc_component *component)/* clock manager reset release */ regmap_write (es8326->regmap,ES8326_RESET ,0x17 );/* set headphone detection as half scan mode */ -regmap_write (es8326->regmap,ES8326_HP_MISC ,0x30 ); +regmap_write (es8326->regmap,ES8326_HP_MISC ,0x3d );regmap_write (es8326->regmap,ES8326_PULLUP_CTL ,0x00 );/* enable headphone driver */ +regmap_write (es8326->regmap,ES8326_HP_VOL ,0xc4 );regmap_write (es8326->regmap,ES8326_HP_DRIVER ,0xa7 );usleep_range (2000 ,5000 ); -regmap_write (es8326->regmap,ES8326_HP_DRIVER_REF ,0xa3 ); -regmap_write (es8326->regmap,ES8326_HP_DRIVER_REF ,0xb3 ); +regmap_write (es8326->regmap,ES8326_HP_DRIVER_REF ,0x23 ); +regmap_write (es8326->regmap,ES8326_HP_DRIVER_REF ,0x33 );regmap_write (es8326->regmap,ES8326_HP_DRIVER ,0xa1 );regmap_write (es8326->regmap,ES8326_CLK_INV ,0x00 );
@@ -827,7 +832,7 @@ static int es8326_resume(struct snd_soc_component *component) (ES8326_IO_DMIC_CLK << ES8326_SDINOUT1_SHIFT));regmap_write (es8326->regmap,ES8326_SDINOUT23_IO ,ES8326_IO_INPUT ); -regmap_write (es8326->regmap,ES8326_ANA_PDN ,0x3b ); +regmap_write (es8326->regmap,ES8326_ANA_PDN ,0x00 );regmap_write (es8326->regmap,ES8326_RESET ,ES8326_CSM_ON );regmap_update_bits (es8326->regmap,ES8326_PGAGAIN ,ES8326_MIC_SEL_MASK ,ES8326_MIC1_SEL );
sound/soc/codecs/es8326.h +1 -1
@@ -100,7 +100,7 @@#define ES8326_MUTE (3 << 0)/* ES8326_CLK_CTL */ -#define ES8326_CLK_ON (0x7f << 0) +#define ES8326_CLK_ON (0x7e << 0)#define ES8326_CLK_OFF (0 << 0)/* ES8326_CLK_INV */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2071/3318 ASoC: codecs: ES8326: Minimize the pop noise on headphone
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhu Ning <[email protected]>
[ Upstream commit a3aa9255d6ccb1bff13c7c98e5d3bf10ba67f92e ]
We modify the register settings to minimize headphone pop noise during ES8326 power-up and music start/stop.
Stable-dep-of: 349e94679968 ("ASoC: es8326: report resume restore errors")
--- sound/soc/codecs/es8326.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-)
sound/soc/codecs/es8326.c +20 -16
@@ -404,7 +404,8 @@ static int es8326_mute(struct snd_soc_dai *dai, int mute, int direction)regmap_write (es8326->regmap,ES8326_HP_CAL ,ES8326_HP_OFF );regmap_update_bits (es8326->regmap,ES8326_DAC_MUTE ,ES8326_MUTE_MASK ,ES8326_MUTE ); -regmap_write (es8326->regmap,ES8326_HP_DRIVER ,0xf0 ); +regmap_update_bits (es8326->regmap,ES8326_HP_DRIVER_REF , +0x30 ,0x00 ); }else {if (!es8326->calibrated) {regmap_write (es8326->regmap,ES8326_HP_CAL ,ES8326_HP_FORCE_CAL );
@@ -417,8 +418,13 @@ static int es8326_mute(struct snd_soc_dai *dai, int mute, int direction)regmap_write (es8326->regmap,ES8326_HPR_OFFSET_INI , offset_r); es8326->calibrated = true; } +regmap_update_bits (es8326->regmap,ES8326_DAC_DSM ,0x01 ,0x01 ); +usleep_range (1000 ,5000 ); +regmap_update_bits (es8326->regmap,ES8326_DAC_DSM ,0x01 ,0x00 ); +usleep_range (1000 ,5000 ); +regmap_update_bits (es8326->regmap,ES8326_HP_DRIVER_REF ,0x30 ,0x20 ); +regmap_update_bits (es8326->regmap,ES8326_HP_DRIVER_REF ,0x30 ,0x30 );regmap_write (es8326->regmap,ES8326_HP_DRIVER ,0xa1 ); -regmap_write (es8326->regmap,ES8326_HP_VOL ,0x91 );regmap_write (es8326->regmap,ES8326_HP_CAL ,ES8326_HP_ON );regmap_update_bits (es8326->regmap,ES8326_DAC_MUTE ,ES8326_MUTE_MASK , ~(ES8326_MUTE ));
@@ -438,23 +444,20 @@ static int es8326_set_bias_level(struct snd_soc_component *codec,if (ret)return ret; -regmap_update_bits (es8326->regmap,ES8326_DAC_DSM ,0x01 ,0x00 ); +regmap_update_bits (es8326->regmap,ES8326_RESET ,0x02 ,0x02 ); +usleep_range (5000 ,10000 );regmap_write (es8326->regmap,ES8326_INTOUT_IO , es8326->interrupt_clk);regmap_write (es8326->regmap,ES8326_SDINOUT1_IO , (ES8326_IO_DMIC_CLK <<ES8326_SDINOUT1_SHIFT )); -regmap_write (es8326->regmap,ES8326_VMIDSEL ,0x0E );regmap_write (es8326->regmap,ES8326_PGA_PDN ,0x40 );regmap_write (es8326->regmap,ES8326_ANA_PDN ,0x00 );regmap_update_bits (es8326->regmap,ES8326_CLK_CTL ,0x20 ,0x20 ); - -regmap_update_bits (es8326->regmap,ES8326_RESET , -ES8326_CSM_ON ,ES8326_CSM_ON ); +regmap_update_bits (es8326->regmap,ES8326_RESET ,0x02 ,0x00 );break ;case SND_SOC_BIAS_PREPARE :break ;case SND_SOC_BIAS_STANDBY :regmap_write (es8326->regmap,ES8326_ANA_PDN ,0x3b ); -regmap_write (es8326->regmap,ES8326_VMIDSEL ,0x00 );regmap_update_bits (es8326->regmap,ES8326_CLK_CTL ,0x20 ,0x00 );regmap_write (es8326->regmap,ES8326_SDINOUT1_IO ,ES8326_IO_INPUT );break ;
@@ -660,6 +663,7 @@ static void es8326_jack_detect_handler(struct work_struct *work)* Don't report jack status. */ regmap_update_bits (es8326->regmap,ES8326_HPDET_TYPE ,0x03 ,0x01 ); +es8326_enable_micbias (es8326->component);usleep_range (50000 ,70000 );regmap_update_bits (es8326->regmap,ES8326_HPDET_TYPE ,0x03 ,0x00 );regmap_write (es8326->regmap,ES8326_SYS_BIAS ,0x1f );
@@ -703,13 +707,10 @@ static void es8326_jack_detect_handler(struct work_struct *work)static irqreturn_t es8326_irq (int irq,void *dev_id) {struct es8326_priv *es8326 = dev_id; -struct snd_soc_component *comp = es8326->component;if (!es8326->jack) goto out; -es8326_enable_micbias (comp); -if (es8326->jack->status &SND_JACK_HEADSET )queue_delayed_work (system_wq, &es8326->jack_detect_work,msecs_to_jiffies (10 ));
@@ -824,6 +825,14 @@ static int es8326_resume(struct snd_soc_component *component)regmap_write (es8326->regmap,ES8326_DAC_DSM ,0x08 );regmap_write (es8326->regmap,ES8326_DAC_VPPSCALE ,0x15 ); +regmap_write (es8326->regmap,ES8326_HPDET_TYPE ,0x80 | + ((es8326->version ==ES8326_VERSION_B ) ? + (ES8326_HP_DET_SRC_PIN9 | es8326->jack_pol) : + (ES8326_HP_DET_SRC_PIN9 | es8326->jack_pol |0x04 ))); +usleep_range (5000 ,10000 ); +es8326_enable_micbias (es8326->component); +usleep_range (50000 ,70000 ); +regmap_update_bits (es8326->regmap,ES8326_HPDET_TYPE ,0x03 ,0x00 );regmap_write (es8326->regmap,ES8326_INT_SOURCE , (ES8326_INT_SRC_PIN9 |ES8326_INT_SRC_BUTTON )); regmap_write(es8326->regmap, ES8326_INTOUT_IO,
@@ -840,11 +849,6 @@ static int es8326_resume(struct snd_soc_component *component)regmap_update_bits (es8326->regmap,ES8326_DAC_MUTE ,ES8326_MUTE_MASK ,ES8326_MUTE ); -regmap_write (es8326->regmap,ES8326_HPDET_TYPE ,0x80 | - ((es8326->version ==ES8326_VERSION_B ) ? - (ES8326_HP_DET_SRC_PIN9 | es8326->jack_pol) : - (ES8326_HP_DET_SRC_PIN9 | es8326->jack_pol |0x04 ))); -regmap_write (es8326->regmap,ES8326_HP_VOL ,0x11 ); es8326->jack_remove_retry =0 ; es8326->hp =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2072/3318 ASoC: codecs: ES8326: fix the capture noise issue
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhu Ning <[email protected]>
[ Upstream commit 8c99a0a607b5e0cf6b79b283d7bb2c2b84e01da5 ]
We get a noise issue during the startup of recording. We update the register setting and dapm widgets to fix this issue.
we change callback type of es8326_mute function to mute_stream. ES8326_ADC_MUTE is moved to es8326_mute function so it can be turned on at last and turned off at first.
Stable-dep-of: 349e94679968 ("ASoC: es8326: report resume restore errors")
--- sound/soc/codecs/es8326.c | 63 ++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 31 deletions(-)
sound/soc/codecs/es8326.c +32 -31
@@ -117,12 +117,6 @@ static const struct snd_soc_dapm_widget es8326_dapm_widgets[] = {SND_SOC_DAPM_AIF_OUT ("I2S OUT" ,"I2S1 Capture" ,0 ,SND_SOC_NOPM ,0 ,0 ),SND_SOC_DAPM_AIF_IN ("I2S IN" ,"I2S1 Playback" ,0 ,SND_SOC_NOPM ,0 ,0 ), -/* ADC Digital Mute */ -SND_SOC_DAPM_PGA ("ADC L1" ,ES8326_ADC_MUTE ,0 ,1 ,NULL ,0 ), -SND_SOC_DAPM_PGA ("ADC R1" ,ES8326_ADC_MUTE ,1 ,1 ,NULL ,0 ), -SND_SOC_DAPM_PGA ("ADC L2" ,ES8326_ADC_MUTE ,2 ,1 ,NULL ,0 ), -SND_SOC_DAPM_PGA ("ADC R2" ,ES8326_ADC_MUTE ,3 ,1 ,NULL ,0 ), -/* Analog Power Supply*/ SND_SOC_DAPM_DAC ("Right DAC" ,NULL ,ES8326_ANA_PDN ,0 ,1 ), SND_SOC_DAPM_DAC("Left DAC", NULL, ES8326_ANA_PDN, 1, 1),
@@ -142,15 +136,10 @@ static const struct snd_soc_dapm_widget es8326_dapm_widgets[] = { };static const struct snd_soc_dapm_route es8326_dapm_routes[] = { - {"ADC L1" ,NULL ,"MIC1" }, - {"ADC R1" ,NULL ,"MIC2" }, - {"ADC L2" ,NULL ,"MIC3" }, - {"ADC R2" ,NULL ,"MIC4" }, - - {"ADC L" ,NULL ,"ADC L1" }, - {"ADC R" ,NULL ,"ADC R1" }, - {"ADC L" ,NULL ,"ADC L2" }, - {"ADC R" ,NULL ,"ADC R2" }, + {"ADC L" ,NULL ,"MIC1" }, + {"ADC R" ,NULL ,"MIC2" }, + {"ADC L" ,NULL ,"MIC3" }, + {"ADC R" ,NULL ,"MIC4" }, {"I2S OUT" ,NULL ,"ADC L" }, {"I2S OUT" ,NULL ,"ADC R" },
@@ -401,11 +390,16 @@ static int es8326_mute(struct snd_soc_dai *dai, int mute, int direction)unsigned int offset_l, offset_r;if (mute) { -regmap_write (es8326->regmap,ES8326_HP_CAL ,ES8326_HP_OFF ); -regmap_update_bits (es8326->regmap,ES8326_DAC_MUTE , -ES8326_MUTE_MASK ,ES8326_MUTE ); -regmap_update_bits (es8326->regmap,ES8326_HP_DRIVER_REF , -0x30 ,0x00 ); +if (direction ==SNDRV_PCM_STREAM_PLAYBACK ) { +regmap_write (es8326->regmap,ES8326_HP_CAL ,ES8326_HP_OFF ); +regmap_update_bits (es8326->regmap,ES8326_DAC_MUTE , +ES8326_MUTE_MASK ,ES8326_MUTE ); +regmap_update_bits (es8326->regmap,ES8326_HP_DRIVER_REF , +0x30 ,0x00 ); + }else { +regmap_update_bits (es8326->regmap,ES8326_ADC_MUTE , +0x0F ,0x0F ); + } }else {if (!es8326->calibrated) {regmap_write (es8326->regmap,ES8326_HP_CAL ,ES8326_HP_FORCE_CAL );
@@ -418,16 +412,22 @@ static int es8326_mute(struct snd_soc_dai *dai, int mute, int direction)regmap_write (es8326->regmap,ES8326_HPR_OFFSET_INI , offset_r); es8326->calibrated = true; } -regmap_update_bits (es8326->regmap,ES8326_DAC_DSM ,0x01 ,0x01 ); -usleep_range (1000 ,5000 ); -regmap_update_bits (es8326->regmap,ES8326_DAC_DSM ,0x01 ,0x00 ); -usleep_range (1000 ,5000 ); -regmap_update_bits (es8326->regmap,ES8326_HP_DRIVER_REF ,0x30 ,0x20 ); -regmap_update_bits (es8326->regmap,ES8326_HP_DRIVER_REF ,0x30 ,0x30 ); -regmap_write (es8326->regmap,ES8326_HP_DRIVER ,0xa1 ); -regmap_write (es8326->regmap,ES8326_HP_CAL ,ES8326_HP_ON ); -regmap_update_bits (es8326->regmap,ES8326_DAC_MUTE , -ES8326_MUTE_MASK , ~(ES8326_MUTE )); +if (direction ==SNDRV_PCM_STREAM_PLAYBACK ) { +regmap_update_bits (es8326->regmap,ES8326_DAC_DSM ,0x01 ,0x01 ); +usleep_range (1000 ,5000 ); +regmap_update_bits (es8326->regmap,ES8326_DAC_DSM ,0x01 ,0x00 ); +usleep_range (1000 ,5000 ); +regmap_update_bits (es8326->regmap,ES8326_HP_DRIVER_REF ,0x30 ,0x20 ); +regmap_update_bits (es8326->regmap,ES8326_HP_DRIVER_REF ,0x30 ,0x30 ); +regmap_write (es8326->regmap,ES8326_HP_DRIVER ,0xa1 ); +regmap_write (es8326->regmap,ES8326_HP_CAL ,ES8326_HP_ON ); +regmap_update_bits (es8326->regmap,ES8326_DAC_MUTE , +ES8326_MUTE_MASK , ~(ES8326_MUTE )); + }else { +msleep (300 ); +regmap_update_bits (es8326->regmap,ES8326_ADC_MUTE , +0x0F ,0x00 ); + } }return 0 ; }
@@ -477,7 +477,7 @@ static const struct snd_soc_dai_ops es8326_ops = { .set_fmt = es8326_set_dai_fmt, .set_sysclk = es8326_set_dai_sysclk, .mute_stream = es8326_mute, - .no_capture_mute = 1, + .no_capture_mute = 0, };static struct snd_soc_dai_driver es8326_dai = {
@@ -849,6 +849,7 @@ static int es8326_resume(struct snd_soc_component *component)regmap_update_bits (es8326->regmap,ES8326_DAC_MUTE ,ES8326_MUTE_MASK ,ES8326_MUTE ); +regmap_write (es8326->regmap,ES8326_ADC_MUTE ,0x0f ); es8326->jack_remove_retry =0 ; es8326->hp =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2073/3318 ASoC: codecs: ES8326: Solve error interruption issue
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Yi <[email protected]>
[ Upstream commit 8a655cee6c9d4588570ad0cb099c5660f9a44a12 ]
We got an error report about headphone type detection and button detection. We fixed the headphone type detection error by adjusting the debounce timer configuration. And we fixed the button detection error by disabling the button detection feature when the headphone are unplugged and enabling it when headphone are plugged in.
Stable-dep-of: 349e94679968 ("ASoC: es8326: report resume restore errors")
--- sound/soc/codecs/es8326.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
sound/soc/codecs/es8326.c +5 -3
@@ -640,6 +640,7 @@ static void es8326_jack_detect_handler(struct work_struct *work)regmap_update_bits (es8326->regmap,ES8326_HPDET_TYPE ,0x03 ,0x01 );regmap_write (es8326->regmap,ES8326_SYS_BIAS ,0x0a );regmap_update_bits (es8326->regmap,ES8326_HP_DRIVER_REF ,0x0f ,0x03 ); +regmap_write (es8326->regmap,ES8326_INT_SOURCE ,ES8326_INT_SRC_PIN9 );/* * Inverted HPJACK_POL bit to trigger one IRQ to double check HP Removal event */
@@ -662,6 +663,8 @@ static void es8326_jack_detect_handler(struct work_struct *work)* set auto-check mode, then restart jack_detect_work after 100ms. * Don't report jack status. */ +regmap_write (es8326->regmap,ES8326_INT_SOURCE , + (ES8326_INT_SRC_PIN9 |ES8326_INT_SRC_BUTTON ));regmap_update_bits (es8326->regmap,ES8326_HPDET_TYPE ,0x03 ,0x01 );es8326_enable_micbias (es8326->component);usleep_range (50000 ,70000 );
@@ -784,7 +787,7 @@ static int es8326_resume(struct snd_soc_component *component)regmap_write (es8326->regmap,ES8326_VMIDSEL ,0x0E );regmap_write (es8326->regmap,ES8326_ANA_LP ,0xf0 );usleep_range (10000 ,15000 ); -regmap_write (es8326->regmap,ES8326_HPJACK_TIMER ,0xe9 ); +regmap_write (es8326->regmap,ES8326_HPJACK_TIMER ,0xd9 );regmap_write (es8326->regmap,ES8326_ANA_MICBIAS ,0xcb );/* set headphone default type and detect pin */ regmap_write (es8326->regmap,ES8326_HPDET_TYPE ,0x83 );
@@ -833,8 +836,7 @@ static int es8326_resume(struct snd_soc_component *component)es8326_enable_micbias (es8326->component);usleep_range (50000 ,70000 );regmap_update_bits (es8326->regmap,ES8326_HPDET_TYPE ,0x03 ,0x00 ); -regmap_write (es8326->regmap,ES8326_INT_SOURCE , - (ES8326_INT_SRC_PIN9 |ES8326_INT_SRC_BUTTON )); +regmap_write (es8326->regmap,ES8326_INT_SOURCE ,ES8326_INT_SRC_PIN9 );regmap_write (es8326->regmap,ES8326_INTOUT_IO , es8326->interrupt_clk); regmap_write(es8326->regmap, ES8326_SDINOUT1_IO,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2074/3318 ASoC: codecs: ES8326: Minimize the pop noise
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Yi <[email protected]>
[ Upstream commit 7e7dbdee96cbc660e7e8d3d9d7a512acaa6ca69d ]
Executing regcache_sync at initialization, we can hear a gentle pop noise. So we created es8326_init for initialization instead of executing es8326_resume
Stable-dep-of: 349e94679968 ("ASoC: es8326: report resume restore errors")
--- sound/soc/codecs/es8326.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-)
sound/soc/codecs/es8326.c +24 -7
@@ -775,14 +775,10 @@ static int es8326_calibrate(struct snd_soc_component *component)return 0 ; } -static int es8326_resume (struct snd_soc_component *component) +static void es8326_init (struct snd_soc_component *component) {struct es8326_priv *es8326 =snd_soc_component_get_drvdata (component); -regcache_cache_only (es8326->regmap, false); -regcache_sync (es8326->regmap); - -/* reset internal clock state */ regmap_write (es8326->regmap,ES8326_RESET ,0x1f );regmap_write (es8326->regmap,ES8326_VMIDSEL ,0x0E );regmap_write (es8326->regmap,ES8326_ANA_LP ,0xf0 );
@@ -836,7 +832,6 @@ static int es8326_resume(struct snd_soc_component *component)es8326_enable_micbias (es8326->component);usleep_range (50000 ,70000 );regmap_update_bits (es8326->regmap,ES8326_HPDET_TYPE ,0x03 ,0x00 ); -regmap_write (es8326->regmap,ES8326_INT_SOURCE ,ES8326_INT_SRC_PIN9 );regmap_write (es8326->regmap,ES8326_INTOUT_IO , es8326->interrupt_clk); regmap_write(es8326->regmap, ES8326_SDINOUT1_IO,
@@ -852,6 +847,28 @@ static int es8326_resume(struct snd_soc_component *component) ES8326_MUTE);regmap_write (es8326->regmap,ES8326_ADC_MUTE ,0x0f ); +regmap_write (es8326->regmap,ES8326_CLK_DIV_LRCK ,0xff ); + +msleep (200 ); +regmap_write (es8326->regmap,ES8326_INT_SOURCE ,ES8326_INT_SRC_PIN9 ); +} + +static int es8326_resume (struct snd_soc_component *component) +{ +struct es8326_priv *es8326 =snd_soc_component_get_drvdata (component); +unsigned int reg; + +regcache_cache_only (es8326->regmap, false); +regcache_cache_bypass (es8326->regmap, true); +regmap_read (es8326->regmap,ES8326_CLK_RESAMPLE , ®); +regcache_cache_bypass (es8326->regmap, false); +/* reset internal clock state */ +if (reg ==0x05 ) +regmap_write (es8326->regmap,ES8326_CLK_CTL ,ES8326_CLK_ON ); +else +es8326_init (component); + +regcache_sync (es8326->regmap); es8326->jack_remove_retry =0 ; es8326->hp =0 ;
@@ -922,7 +939,7 @@ static int es8326_probe(struct snd_soc_component *component) }dev_dbg (component->dev,"interrupt-clk %x" , es8326->interrupt_clk); -es8326_resume (component); +es8326_init (component);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2075/3318 ASoC: es8326: report resume restore errors
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 349e94679968785803cc32c1d2e41e000e8afd5f ]
es8326_resume() ignores the status-register read, the direct clock-state write and the register-cache replay. A read failure can also leave reg uninitialized before it selects the reset path, and a cache failure is followed by jack IRQ processing.
Return these errors before later resume work. The ASoC component wrapper reports the callback failure while retaining its best-effort resume contract.
The issue was found by our static-analysis tool and manually reviewed.
--- sound/soc/codecs/es8326.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
sound/soc/codecs/es8326.c +15 -5
@@ -857,18 +857,28 @@ static int es8326_resume(struct snd_soc_component *component) {struct es8326_priv *es8326 =snd_soc_component_get_drvdata (component);unsigned int reg; +int ret;regcache_cache_only (es8326->regmap, false);regcache_cache_bypass (es8326->regmap, true); -regmap_read (es8326->regmap,ES8326_CLK_RESAMPLE , ®); + ret =regmap_read (es8326->regmap,ES8326_CLK_RESAMPLE , ®);regcache_cache_bypass (es8326->regmap, false); +if (ret) +return ret; +/* reset internal clock state */ -if (reg ==0x05 ) -regmap_write (es8326->regmap,ES8326_CLK_CTL ,ES8326_CLK_ON ); -else +if (reg ==0x05 ) { + ret =regmap_write (es8326->regmap,ES8326_CLK_CTL , +ES8326_CLK_ON ); +if (ret) +return ret; + }else {es8326_init (component); + } -regcache_sync (es8326->regmap); + ret =regcache_sync (es8326->regmap); +if (ret) +return ret; es8326->jack_remove_retry =0 ; es8326->hp =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2076/3318 virtio_ccw: fix synchronize_cbs() after interrupt fallback
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 6e484b870b71eb6acb3fa7a10b8e71098e242033 ]
virtio_ccw_synchronize_cbs() assumes the device uses adapter interrupts when vcdev->airq_info is not NULL. If registering adapter indicators fails, virtio_ccw_find_vqs() falls back to classic interrupts but can leave airq_info set.
With VIRTIO_HARDEN_NOTIFICATION enabled, virtio_ccw_int_handler() invokes callbacks under vcdev->irq_lock. synchronize_cbs() instead takes the indicator area lock, so it does not synchronize with those callbacks.
Use vcdev->is_thinint, which the fallback clears, to select the lock. Keep the airq_info check because is_thinint can be set before the first find_vqs() call, when airq_info is still NULL.
Message-ID: <[email protected]>
--- drivers/s390/virtio/virtio_ccw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/virtio/virtio_ccw.c +1 -1
@@ -1016,7 +1016,7 @@ static void virtio_ccw_synchronize_cbs(struct virtio_device *vdev)struct virtio_ccw_device *vcdev =to_vc_device (vdev);struct airq_info *info = vcdev->airq_info; -if (info) { +if (vcdev->is_thinint && info) {/* * This device uses adapter interrupts: synchronize with * vring_interrupt() called by virtio_airq_handler()
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2077/3318 virtio_ccw: always take irq_lock in the classic interrupt handler
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 48a355cf5b382570975e60857450ff3d42f268e9 ]
virtio_ccw_int_handler() takes vcdev->irq_lock around its vring_interrupt() calls only when VIRTIO_HARDEN_NOTIFICATION is enabled.
The virtio shutdown path calls synchronize_cbs() even when notification hardening is disabled. virtio_reset_device() now does so after the transport reset too.
For classic interrupts, synchronize_cbs() takes vcdev->irq_lock for writing, but the interrupt handler does not take the matching read lock in that configuration. synchronize_cbs() can return while a callback is still running.
Take the read lock unconditionally so the write side can synchronize with the callbacks.
Message-ID: <[email protected]>
--- drivers/s390/virtio/virtio_ccw.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/s390/virtio/virtio_ccw.c +0 -4
@@ -1158,13 +1158,11 @@ static void virtio_ccw_int_handler(struct ccw_device *cdev, vcdev->err = -EIO ; }virtio_ccw_check_activity (vcdev, activity); -#ifdef CONFIG_VIRTIO_HARDEN_NOTIFICATION /* * Paired with virtio_ccw_synchronize_cbs() and interrupts are * disabled here. */ read_lock (&vcdev->irq_lock); -#endif for_each_set_bit (i,indicators (vcdev),sizeof (*indicators (vcdev)) *BITS_PER_BYTE ) {/* The bit clear must happen before the vring kick. */
@@ -1173,9 +1171,7 @@ static void virtio_ccw_int_handler(struct ccw_device *cdev, vq =virtio_ccw_vq_by_ind (vcdev, i);vring_interrupt (0 , vq); } -#ifdef CONFIG_VIRTIO_HARDEN_NOTIFICATION read_unlock (&vcdev->irq_lock); -#endif if (test_bit (0 ,indicators2 (vcdev))) {virtio_config_changed (&vcdev->vdev);clear_bit (0 ,indicators2 (vcdev));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2078/3318 pwm: mtk-disp: Fix period readback
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen-Yu Tsai <[email protected]>
[ Upstream commit c5b29baad42b2b02389cc6a716697a8a63209930 ]
The period value stored in the register is the number of clock cycles - 1.
Account for the offset when calculating the period in nanoseconds. This fixes the discrepancy reported by the pwm core when CONFIG_PWM_DEBUG=1:
mediatek-disp-pwm 1100e000.pwm: .apply is not idempotent
(ena=1 pol=0 281500/499875) -> (ena=1 pol=0 281500/499750)
Calculation discrepancy in the driver was found by AI run by a colleague while debugging another PWM related issue. Check against SoC datasheet and fix done by the author.
--- drivers/pwm/pwm-mtk-disp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pwm/pwm-mtk-disp.c +2 -2
@@ -211,9 +211,9 @@ static int mtk_disp_pwm_get_state(struct pwm_chip *chip, period =FIELD_GET (PWM_PERIOD_MASK , con1);/* * period has 12 bits, clk_div 11 and NSEC_PER_SEC has 30, -* so period * (clk_div + 1) * NSEC_PER_SEC doesn't overflow. +* so (period + 1) * (clk_div + 1) * NSEC_PER_SEC doesn't overflow. */ - state->period =DIV64_U64_ROUND_UP (period * (clk_div +1 ) *NSEC_PER_SEC , rate); + state->period =DIV64_U64_ROUND_UP ((period +1 ) * (clk_div +1 ) *NSEC_PER_SEC , rate); high_width =FIELD_GET (PWM_HIGH_WIDTH_MASK , con1); state->duty_cycle =DIV64_U64_ROUND_UP (high_width * (clk_div +1 ) *NSEC_PER_SEC , rate);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2079/3318 mac80211: tx: Use info->flags in ieee80211_tx_h_select_key()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bert Karwatzki <[email protected]>
[ Upstream commit 5f2530a4df8e0573e54cc0f4175c06ecb810a4dd ]
Without this ieee80211_select_key_8023() is never called and wifi never connects.
--- net/mac80211/tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/tx.c +1 -1
@@ -632,7 +632,7 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)struct ieee80211_tx_info *info =IEEE80211_SKB_CB (tx->skb);struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; -if (info->control.flags &IEEE80211_TX_CTL_HW_80211_ENCAP ) +if (info->flags &IEEE80211_TX_CTL_HW_80211_ENCAP )return ieee80211_select_key_8023 (tx);if (unlikely (info->flags &IEEE80211_TX_INTFL_DONT_ENCRYPT )) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2080/3318 ASoC: mediatek: mt8186: Fix APLL mux setting error handling
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 5ee5987fadf6ae15678a654b4d909225c97f0299 ]
The APLL mux setup functions return immediately when a clock operation fails, without undoing the clock changes already made. This can leave clocks enabled or muxes configured to an unexpected parent.
Restore the affected muxes to CLK26M and disable previously enabled clocks on error before propagating the original error.
--- sound/soc/mediatek/mt8186/mt8186-afe-clk.c | 50 ++++++++++++++++------ 1 file changed, 38 insertions(+), 12 deletions(-)
sound/soc/mediatek/mt8186/mt8186-afe-clk.c +38 -12
@@ -98,7 +98,7 @@ static int apll1_mux_setting(struct mtk_base_afe *afe, bool enable)if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_1 ], ret); -return ret; + goto ERR_ENABLE_CLK_TOP_MUX_AUD_1; } ret =clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_1 ], afe_priv->clk[CLK_TOP_APLL1_CK ]);
@@ -106,7 +106,7 @@ static int apll1_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_1 ], aud_clks[CLK_TOP_APLL1_CK ], ret); -return ret; + goto ERR_SELECT_CLK_TOP_MUX_AUD_1; }/* 180.6336 / 8 = 22.5792MHz */
@@ -114,7 +114,7 @@ static int apll1_mux_setting(struct mtk_base_afe *afe, bool enable)if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_ENG1 ], ret); -return ret; + goto ERR_ENABLE_CLK_TOP_MUX_AUD_ENG1; } ret =clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_ENG1 ], afe_priv->clk[CLK_TOP_APLL1_D8 ]);
@@ -122,7 +122,7 @@ static int apll1_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_ENG1 ], aud_clks[CLK_TOP_APLL1_D8 ], ret); -return ret; + goto ERR_SELECT_CLK_TOP_MUX_AUD_ENG1; } }else { ret = clk_set_parent(afe_priv->clk[CLK_TOP_MUX_AUD_ENG1],
@@ -131,7 +131,7 @@ static int apll1_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_ENG1 ], aud_clks[CLK_CLK26M ], ret); -return ret; + goto EXIT; }clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_ENG1 ]);
@@ -141,12 +141,25 @@ static int apll1_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_1 ], aud_clks[CLK_CLK26M ], ret); -return ret; + goto EXIT; }clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_1 ]); }return 0 ; + +ERR_SELECT_CLK_TOP_MUX_AUD_ENG1: +clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_ENG1 ], + afe_priv->clk[CLK_CLK26M ]); +clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_ENG1 ]); +ERR_ENABLE_CLK_TOP_MUX_AUD_ENG1: +ERR_SELECT_CLK_TOP_MUX_AUD_1: +clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_1 ], + afe_priv->clk[CLK_CLK26M ]); +clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_1 ]); +ERR_ENABLE_CLK_TOP_MUX_AUD_1: +EXIT: +return ret; }static int apll2_mux_setting (struct mtk_base_afe *afe,bool enable)
@@ -159,7 +172,7 @@ static int apll2_mux_setting(struct mtk_base_afe *afe, bool enable)if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_2 ], ret); -return ret; + goto ERR_ENABLE_CLK_TOP_MUX_AUD_2; } ret =clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_2 ], afe_priv->clk[CLK_TOP_APLL2_CK ]);
@@ -167,7 +180,7 @@ static int apll2_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_2 ], aud_clks[CLK_TOP_APLL2_CK ], ret); -return ret; + goto ERR_SELECT_CLK_TOP_MUX_AUD_2; }/* 196.608 / 8 = 24.576MHz */
@@ -175,7 +188,7 @@ static int apll2_mux_setting(struct mtk_base_afe *afe, bool enable)if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_ENG2 ], ret); -return ret; + goto ERR_ENABLE_CLK_TOP_MUX_AUD_ENG2; } ret =clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_ENG2 ], afe_priv->clk[CLK_TOP_APLL2_D8 ]);
@@ -183,7 +196,7 @@ static int apll2_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_ENG2 ], aud_clks[CLK_TOP_APLL2_D8 ], ret); -return ret; + goto ERR_SELECT_CLK_TOP_MUX_AUD_ENG2; } }else { ret = clk_set_parent(afe_priv->clk[CLK_TOP_MUX_AUD_ENG2],
@@ -192,7 +205,7 @@ static int apll2_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_ENG2 ], aud_clks[CLK_CLK26M ], ret); -return ret; + goto EXIT; }clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_ENG2 ]);
@@ -202,12 +215,25 @@ static int apll2_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_2 ], aud_clks[CLK_CLK26M ], ret); -return ret; + goto EXIT; }clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_2 ]); }return 0 ; + +ERR_SELECT_CLK_TOP_MUX_AUD_ENG2: +clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_ENG2 ], + afe_priv->clk[CLK_CLK26M ]); +clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_ENG2 ]); +ERR_ENABLE_CLK_TOP_MUX_AUD_ENG2: +ERR_SELECT_CLK_TOP_MUX_AUD_2: +clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_2 ], + afe_priv->clk[CLK_CLK26M ]); +clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_2 ]); +ERR_ENABLE_CLK_TOP_MUX_AUD_2: +EXIT: +return ret; }int mt8186_afe_enable_cgs (struct mtk_base_afe *afe)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2081/3318 ASoC: mediatek: mt8186: Fix clock handling in mux disable path
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit d70109f5510b423e72894dadfbab27087a7b26b0 ]
In the disable path of the appl*_mux_setting() functions, clk_disable_unprepare() is called after clk_set_parent(). If clk_set_parent() fails, clk_disable_unprepare() is skipped, potentially leaving one of the clocks enabled.
Remove the goto exit paths so that all teardown steps are attempted and any errors are only reported.
--- sound/soc/mediatek/mt8186/mt8186-afe-clk.c | 6 ------ 1 file changed, 6 deletions(-)
sound/soc/mediatek/mt8186/mt8186-afe-clk.c +0 -6
@@ -131,7 +131,6 @@ static int apll1_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_ENG1 ], aud_clks[CLK_CLK26M ], ret); - goto EXIT; }clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_ENG1 ]);
@@ -141,7 +140,6 @@ static int apll1_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_1 ], aud_clks[CLK_CLK26M ], ret); - goto EXIT; }clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_1 ]); }
@@ -158,7 +156,6 @@ static int apll1_mux_setting(struct mtk_base_afe *afe, bool enable) afe_priv->clk[CLK_CLK26M]);clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_1 ]); ERR_ENABLE_CLK_TOP_MUX_AUD_1: -EXIT:return ret; }
@@ -205,7 +202,6 @@ static int apll2_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_ENG2 ], aud_clks[CLK_CLK26M ], ret); - goto EXIT; }clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_ENG2 ]);
@@ -215,7 +211,6 @@ static int apll2_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_2 ], aud_clks[CLK_CLK26M ], ret); - goto EXIT; }clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_2 ]); }
@@ -232,7 +227,6 @@ static int apll2_mux_setting(struct mtk_base_afe *afe, bool enable) afe_priv->clk[CLK_CLK26M]);clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_2 ]); ERR_ENABLE_CLK_TOP_MUX_AUD_2: -EXIT:return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2082/3318 ASoC: mediatek: mt8186: Fix AFE clock error handling
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit eb72060a1966baf9a6ed753186621ee6e39dc889 ]
The error paths in mt8186_afe_enable_clock() do not consistently undo the clock operations performed before an error.
Fix the goto targets and cleanup order so that the audio internal bus parent is restored to CLK26M and all previously enabled clocks are disabled before returning the error.
--- sound/soc/mediatek/mt8186/mt8186-afe-clk.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
sound/soc/mediatek/mt8186/mt8186-afe-clk.c +8 -10
@@ -288,7 +288,7 @@ int mt8186_afe_enable_clock(struct mtk_base_afe *afe)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_MUX_AUDIO ], aud_clks[CLK_CLK26M ], ret); - goto clk_mux_audio_err; + goto clk_mux_audio_intbus_err; } ret =clk_prepare_enable (afe_priv->clk[CLK_MUX_AUDIOINTBUS ]);
@@ -315,24 +315,22 @@ int mt8186_afe_enable_clock(struct mtk_base_afe *afe)if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_AFE ], ret); - goto clk_afe_err; + goto clk_mux_audio_h_parent_err; }return 0 ; -clk_afe_err: -clk_disable_unprepare (afe_priv->clk[CLK_AFE ]); clk_mux_audio_h_parent_err: -clk_mux_audio_intbus_parent_err:mt8186_set_audio_int_bus_parent (afe,CLK_CLK26M ); -clk_mux_audio_intbus_err: +clk_mux_audio_intbus_parent_err:clk_disable_unprepare (afe_priv->clk[CLK_MUX_AUDIOINTBUS ]); -clk_mux_audio_err: +clk_mux_audio_intbus_err:clk_disable_unprepare (afe_priv->clk[CLK_MUX_AUDIO ]); -clk_infra_sys_audio_err: -clk_disable_unprepare (afe_priv->clk[CLK_INFRA_SYS_AUDIO ]); -clk_infra_audio_26m_err: +clk_mux_audio_err:clk_disable_unprepare (afe_priv->clk[CLK_INFRA_AUDIO_26M ]); +clk_infra_audio_26m_err: +clk_disable_unprepare (afe_priv->clk[CLK_INFRA_SYS_AUDIO ]); +clk_infra_sys_audio_err:return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2083/3318 ASoC: mediatek: mt8186: Fix APLL enable error handling
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit cb552c6b9abe02f254d44d8c29d0dce1ae21f69f ]
Currently, the mt8186_apll*_enable() functions call mux_setting(afe, true) but do not check its return value to handle failures.
In addition, the cleanup paths of mt8186_apll*_enable() do not call mux_setting(afe, false) when the enable operation fails, while the mt8186_apll*_disable() functions do.
Add error handling for apll*_mux_setting() and call mux_setting(afe, false) in the cleanup paths when mt8186_apll*_enable() fails.
--- sound/soc/mediatek/mt8186/mt8186-afe-clk.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
sound/soc/mediatek/mt8186/mt8186-afe-clk.c +10 -6
@@ -408,7 +408,9 @@ int mt8186_apll1_enable(struct mtk_base_afe *afe)int ret;/* setting for APLL */ -apll1_mux_setting (afe, true); + ret =apll1_mux_setting (afe, true); +if (ret) +return ret; ret =clk_prepare_enable (afe_priv->clk[CLK_APLL22M ]);if (ret) {
@@ -433,9 +435,9 @@ int mt8186_apll1_enable(struct mtk_base_afe *afe)return 0 ; err_clk_apll1_tuner: -clk_disable_unprepare (afe_priv->clk[CLK_APLL1_TUNER ]); -err_clk_apll22m:clk_disable_unprepare (afe_priv->clk[CLK_APLL22M ]); +err_clk_apll22m: +apll1_mux_setting (afe, false);return ret; }
@@ -461,7 +463,9 @@ int mt8186_apll2_enable(struct mtk_base_afe *afe)int ret;/* setting for APLL */ -apll2_mux_setting (afe, true); + ret =apll2_mux_setting (afe, true); +if (ret) +return ret; ret =clk_prepare_enable (afe_priv->clk[CLK_APLL24M ]);if (ret) {
@@ -486,9 +490,9 @@ int mt8186_apll2_enable(struct mtk_base_afe *afe)return 0 ; err_clk_apll2_tuner: -clk_disable_unprepare (afe_priv->clk[CLK_APLL2_TUNER ]); -err_clk_apll24m:clk_disable_unprepare (afe_priv->clk[CLK_APLL24M ]); +err_clk_apll24m: +apll2_mux_setting (afe, false);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2084/3318 ASoC: mediatek: mt8186: Fix MCK error handling
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 996469c1092e8fa81fac98d819174ce56baff821 ]
The mt8186_mck_enable() function returns immediately when a clock operation fails, leaving previously enabled clocks active.
Add error paths to disable previously enabled clocks before returning the error.
--- sound/soc/mediatek/mt8186/mt8186-afe-clk.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
sound/soc/mediatek/mt8186/mt8186-afe-clk.c +13 -4
@@ -575,7 +575,7 @@ int mt8186_mck_enable(struct mtk_base_afe *afe, int mck_id, int rate)if (ret) {dev_err (afe->dev,"%s(), clk_prepare_enable %s fail %d\n" , __func__, aud_clks[m_sel_id], ret); -return ret; + goto ERR_ENABLE_MCLK; } ret =clk_set_parent (afe_priv->clk[m_sel_id], afe_priv->clk[apll_clk_id]);
@@ -583,7 +583,7 @@ int mt8186_mck_enable(struct mtk_base_afe *afe, int mck_id, int rate)dev_err (afe->dev,"%s(), clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[m_sel_id], aud_clks[apll_clk_id], ret); -return ret; + goto ERR_SELECT_MCLK; } }
@@ -592,16 +592,25 @@ int mt8186_mck_enable(struct mtk_base_afe *afe, int mck_id, int rate)if (ret) {dev_err (afe->dev,"%s(), clk_prepare_enable %s fail %d\n" , __func__, aud_clks[div_clk_id], ret); -return ret; + goto ERR_ENABLE_MCLK_DIV; } ret =clk_set_rate (afe_priv->clk[div_clk_id], rate);if (ret) {dev_err (afe->dev,"%s(), clk_set_rate %s, rate %d, fail %d\n" , __func__, aud_clks[div_clk_id], rate, ret); -return ret; + goto ERR_SET_MCLK_RATE; }return 0 ; + +ERR_SET_MCLK_RATE: +clk_disable_unprepare (afe_priv->clk[div_clk_id]); +ERR_ENABLE_MCLK_DIV: +ERR_SELECT_MCLK: +if (m_sel_id >=0 ) +clk_disable_unprepare (afe_priv->clk[m_sel_id]); +ERR_ENABLE_MCLK: +return ret; }void mt8186_mck_disable (struct mtk_base_afe *afe,int mck_id)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2085/3318 ASoC: mediatek: mt6797: fix wrong unwind order and error code in enable_clock
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit e967d479b65c778cd2394ab185e289beefcf996d ]
The error paths in mt6797_afe_enable_clock() use incorrect goto labels, causing clocks that failed to enable to be disabled during cleanup.
Fix the goto labels to only unwind clocks that were successfully enabled, and return the actual error code.
--- sound/soc/mediatek/mt6797/mt6797-afe-clk.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
sound/soc/mediatek/mt6797/mt6797-afe-clk.c +6 -8
@@ -63,21 +63,21 @@ int mt6797_afe_enable_clock(struct mtk_base_afe *afe)if (ret) {dev_err (afe->dev,"%s(), clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_INFRA_SYS_AUD ], ret); - goto CLK_INFRA_SYS_AUDIO_ERR; +return ret; } ret =clk_prepare_enable (afe_priv->clk[CLK_INFRA_SYS_AUD_26M ]);if (ret) {dev_err (afe->dev,"%s(), clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_INFRA_SYS_AUD_26M ], ret); - goto CLK_INFRA_SYS_AUD_26M_ERR; + goto CLK_INFRA_SYS_AUDIO_ERR; } ret =clk_prepare_enable (afe_priv->clk[CLK_TOP_MUX_AUD ]);if (ret) {dev_err (afe->dev,"%s(), clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD ], ret); - goto CLK_MUX_AUDIO_ERR; + goto CLK_INFRA_SYS_AUD_26M_ERR; } ret = clk_set_parent(afe_priv->clk[CLK_TOP_MUX_AUD],
@@ -93,13 +93,11 @@ int mt6797_afe_enable_clock(struct mtk_base_afe *afe)if (ret) {dev_err (afe->dev,"%s(), clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_BUS ], ret); - goto CLK_MUX_AUDIO_INTBUS_ERR; + goto CLK_MUX_AUDIO_ERR; } -return ret; +return 0 ; -CLK_MUX_AUDIO_INTBUS_ERR: -clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_BUS ]); CLK_MUX_AUDIO_ERR:clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD ]); CLK_INFRA_SYS_AUD_26M_ERR:
@@ -107,7 +105,7 @@ int mt6797_afe_enable_clock(struct mtk_base_afe *afe) CLK_INFRA_SYS_AUDIO_ERR:clk_disable_unprepare (afe_priv->clk[CLK_INFRA_SYS_AUD ]); -return 0 ; +return ret; }int mt6797_afe_disable_clock (struct mtk_base_afe *afe)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2086/3318 pwm: lp3943: Drop usage of pwm_[gs]et_chip_data()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit 06cc4767750337ad162a0a7bcfd6f6eff6e0fe92 ]
Instead of distributing the driver's bookkeeping over 3 (i.e. LP3943_NUM_PWMS + 1) separately allocated memory chunks, put all together in struct lp3943_pwm. This reduces the number of memory allocations and so fragmentation and maybe even the number of cache misses. Also &lp3943_pwm->pwm_map[pwm->hwpwm] is cheaper to evaluate than pwm_get_chip_data(pwm) as the former is just an addition in machine code while the latter involves a function call.
Stable-dep-of: 17dbb6938d3a ("pwm: lp3943: fix NULL pointer dereference for an unconfigured channel")
--- drivers/pwm/pwm-lp3943.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-)
drivers/pwm/pwm-lp3943.c +7 -14
@@ -23,6 +23,7 @@ struct lp3943_pwm {struct pwm_chip chip;struct lp3943 *lp3943;struct lp3943_platform_data *pdata; +struct lp3943_pwm_map pwm_map[LP3943_NUM_PWMS ]; };static inline struct lp3943_pwm *to_lp3943_pwm (struct pwm_chip *chip)
@@ -35,13 +36,9 @@ lp3943_pwm_request_map(struct lp3943_pwm *lp3943_pwm, int hwpwm) {struct lp3943_platform_data *pdata = lp3943_pwm->pdata;struct lp3943 *lp3943 = lp3943_pwm->lp3943; -struct lp3943_pwm_map *pwm_map; +struct lp3943_pwm_map *pwm_map = &lp3943_pwm->pwm_map[hwpwm];int i, offset; - pwm_map =kzalloc (sizeof (*pwm_map),GFP_KERNEL ); -if (!pwm_map) -return ERR_PTR (-ENOMEM ); - pwm_map->output = pdata->pwms[hwpwm]->output; pwm_map->num_outputs = pdata->pwms[hwpwm]->num_outputs;
@@ -49,10 +46,8 @@ lp3943_pwm_request_map(struct lp3943_pwm *lp3943_pwm, int hwpwm) offset = pwm_map->output[i];/* Return an error if the pin is already assigned */ -if (test_and_set_bit (offset, &lp3943->pin_used)) { -kfree (pwm_map); +if (test_and_set_bit (offset, &lp3943->pin_used))return ERR_PTR (-EBUSY ); - } }return pwm_map;
@@ -67,7 +62,7 @@ static int lp3943_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)if (IS_ERR (pwm_map))return PTR_ERR (pwm_map); -return pwm_set_chip_data (pwm, pwm_map); +return 0 ; } static void lp3943_pwm_free_map(struct lp3943_pwm *lp3943_pwm,
@@ -80,14 +75,12 @@ static void lp3943_pwm_free_map(struct lp3943_pwm *lp3943_pwm, offset = pwm_map->output[i];clear_bit (offset, &lp3943->pin_used); } - -kfree (pwm_map); }static void lp3943_pwm_free (struct pwm_chip *chip,struct pwm_device *pwm) {struct lp3943_pwm *lp3943_pwm =to_lp3943_pwm (chip); -struct lp3943_pwm_map *pwm_map =pwm_get_chip_data (pwm); +struct lp3943_pwm_map *pwm_map = &lp3943_pwm->pwm_map[pwm->hwpwm];lp3943_pwm_free_map (lp3943_pwm, pwm_map); }
@@ -159,7 +152,7 @@ static int lp3943_pwm_set_mode(struct lp3943_pwm *lp3943_pwm,static int lp3943_pwm_enable (struct pwm_chip *chip,struct pwm_device *pwm) {struct lp3943_pwm *lp3943_pwm =to_lp3943_pwm (chip); -struct lp3943_pwm_map *pwm_map =pwm_get_chip_data (pwm); +struct lp3943_pwm_map *pwm_map = &lp3943_pwm->pwm_map[pwm->hwpwm];u8 val;if (pwm->hwpwm ==0 )
@@ -178,7 +171,7 @@ static int lp3943_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)static void lp3943_pwm_disable (struct pwm_chip *chip,struct pwm_device *pwm) {struct lp3943_pwm *lp3943_pwm =to_lp3943_pwm (chip); -struct lp3943_pwm_map *pwm_map =pwm_get_chip_data (pwm); +struct lp3943_pwm_map *pwm_map = &lp3943_pwm->pwm_map[pwm->hwpwm];/* * LP3943 outputs are open-drain, so the pin should be configured
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2087/3318 pwm: lp3943: fix NULL pointer dereference for an unconfigured channel
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manush Prajwal <[email protected]>
[ Upstream commit 17dbb6938d3ab444cd6be1c95506450595a8800d ]
lp3943_pwm_probe() unconditionally registers a pwmchip with LP3943_NUM_PWMS(2) hwpwm channels, but lp3943_pwm_parse_dt() only populates pdata->pwms[i] for the channels whose ti,pwm0/ti,pwm1 property is actually present in the devicetree (the binding explicitly allows each PWM generator to drive zero or more outputs, and lp3943_pwm_parse_dt() only fails outright with -ENODATA if *neither* property is present). A devicetree that configures only one of the two channels leaves pdata->pwms[] NULL for the other.
lp3943_pwm_request_map() dereferences pdata->pwms[hwpwm] with no NULL check:
pwm_map->output = pdata->pwms[hwpwm]->output; pwm_map->num_outputs = pdata->pwms[hwpwm]->num_outputs;
so requesting the unconfigured channel (e.g. exporting it from sysfs) crashes with a NULL pointer dereference instead of failing cleanly.
Return -ENODEV from lp3943_pwm_request_map() when the channel was never configured, before the pointer is dereferenced. The caller, lp3943_pwm_request(), already propagates an ERR_PTR return correctly (it does so today for the existing -EBUSY case).
--- drivers/pwm/pwm-lp3943.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/pwm/pwm-lp3943.c +3 -0
@@ -39,6 +39,9 @@ lp3943_pwm_request_map(struct lp3943_pwm *lp3943_pwm, int hwpwm)struct lp3943_pwm_map *pwm_map = &lp3943_pwm->pwm_map[hwpwm];int i, offset; +if (!pdata->pwms[hwpwm]) +return ERR_PTR (-ENODEV ); + pwm_map->output = pdata->pwms[hwpwm]->output; pwm_map->num_outputs = pdata->pwms[hwpwm]->num_outputs;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2088/3318 EDAC/i10nm: Fix Granite Rapids ADXL MC mapping
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qiuxu Zhuo <[email protected]>
[ Upstream commit ba71d9b4e9dd83c1614b3b5cec6c82a39d290f7e ]
ADXL reports memory errors using memory-controller physical indices, while the EDAC driver identifies memory controllers using logical indices. On Granite Rapids systems, BIOS may disable some memory controllers, causing the physical and logical indices to differ.
As a result, ADXL memory errors may be associated with the wrong memory controller, preventing EDAC from reporting errors for some DIMMs.
Maintain a physical-to-logical MC mapping so that ADXL memory errors are decoded correctly regardless of the BIOS memory-controller configuration.
--- drivers/edac/i10nm_base.c | 1 + 1 file changed, 1 insertion(+)
drivers/edac/i10nm_base.c +1 -0
@@ -598,6 +598,7 @@ static struct pci_dev *get_gnr_mdev(struct skx_dev *d, int logical_idx, int *phyif (mdev) {if (logical == logical_idx) { *physical_idx = i; +skx_set_mc_mapping (d, i, logical_idx);return mdev; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2089/3318 mtd: spinand: Fix spinand_manufacturer_ops kernel-doc
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 7e874b1750a40f3dc9a629aeb72eba09c77f77e9 ]
The kernel-doc heading for struct spinand_manufacturer_ops misspells and truncates its name as manufacurer_ops. As a result, kernel-doc cannot match the comment to the structure declaration.
Use the structure's actual name.
--- include/linux/mtd/spinand.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mtd/spinand.h +1 -1
@@ -230,7 +230,7 @@ struct spinand_devid { };/** -* struct manufacurer_ops - SPI NAND manufacturer specific operations +* struct spinand_manufacturer_ops - SPI NAND manufacturer specific operations * @init: initialize a SPI NAND device * @cleanup: cleanup a SPI NAND device *
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2090/3318 dmaengine: sun6i-dma: Fix use-after-free in error handling paths
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongling Zeng <[email protected]>
[ Upstream commit f472919f4c0650d7fb22bb230eacaada0c6ee951 ]
In error handling paths, the for loop frees v_lli in the loop body, then accesses v_lli->v_lli_next and v_lli->p_lli_next in the increment expression, which is use-after-free.
Fix by refactoring the cleanup into a helper function sun6i_dma_free_desc() that saves both the next virtual and physical pointers before freeing the current node, preventing the use-after-free.
--- drivers/dma/sun6i-dma.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
drivers/dma/sun6i-dma.c +16 -15
@@ -407,16 +407,12 @@ static inline void sun6i_dma_dump_lli(struct sun6i_vchan *vchan, v_lli->len, v_lli->para, v_lli->p_lli_next); } -static void sun6i_dma_free_desc (struct virt_dma_desc *vd) +static void sun6i_dma_free_desc (struct sun6i_dma_dev *sdev, +struct sun6i_desc *txd) { -struct sun6i_desc *txd =to_sun6i_desc (&vd->tx); -struct sun6i_dma_dev *sdev =to_sun6i_dma_dev (vd->tx.chan->device);struct sun6i_dma_lli *v_lli, *v_next;dma_addr_t p_lli, p_next; -if (unlikely (!txd)) -return ; - p_lli = txd->p_lli; v_lli = txd->v_lli;
@@ -433,6 +429,17 @@ static void sun6i_dma_free_desc(struct virt_dma_desc *vd)kfree (txd); } +static void sun6i_dma_free_desc_virt (struct virt_dma_desc *vd) +{ +struct sun6i_desc *txd =to_sun6i_desc (&vd->tx); +struct sun6i_dma_dev *sdev =to_sun6i_dma_dev (vd->tx.chan->device); + +if (unlikely (!txd)) +return ; + +sun6i_dma_free_desc (sdev, txd); +} +static int sun6i_dma_start_desc (struct sun6i_vchan *vchan) {struct sun6i_dma_dev *sdev =to_sun6i_dma_dev (vchan->vc.chan.device);
@@ -789,10 +796,7 @@ static struct dma_async_tx_descriptor *sun6i_dma_prep_slave_sg(return vchan_tx_prep (&vchan->vc, &txd->vd, flags); err_lli_free: -for (p_lli = txd->p_lli, v_lli = txd->v_lli; v_lli; - p_lli = v_lli->p_lli_next, v_lli = v_lli->v_lli_next) -dma_pool_free (sdev->pool, v_lli, p_lli); -kfree (txd); +sun6i_dma_free_desc (sdev, txd);return NULL ; }
@@ -860,10 +864,7 @@ static struct dma_async_tx_descriptor *sun6i_dma_prep_dma_cyclic(return vchan_tx_prep (&vchan->vc, &txd->vd, flags); err_lli_free: -for (p_lli = txd->p_lli, v_lli = txd->v_lli; v_lli; - p_lli = v_lli->p_lli_next, v_lli = v_lli->v_lli_next) -dma_pool_free (sdev->pool, v_lli, p_lli); -kfree (txd); +sun6i_dma_free_desc (sdev, txd);return NULL ; }
@@ -1418,7 +1419,7 @@ static int sun6i_dma_probe(struct platform_device *pdev)struct sun6i_vchan *vchan = &sdc->vchans[i];INIT_LIST_HEAD (&vchan->node); - vchan->vc.desc_free = sun6i_dma_free_desc; + vchan->vc.desc_free = sun6i_dma_free_desc_virt;vchan_init (&vchan->vc, &sdc->slave); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2091/3318 dmaengine: at_hdmac: Fix use-after-free by proper tasklet cleanup
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongling Zeng <[email protected]>
[ Upstream commit 13f2d32a09609d083ace2d589fbdc68e970ae34c ]
Current cleanup paths have a use-after-free vulnerability:
- vchan_init() creates tasklets that access at_dma_chan memory
- free_irq() only waits for IRQ handler, NOT tasklets
- atdma is devm-managed and freed after probe/remove
- Running tasklets accessing freed memory → Use-After-Free!
The fix requires careful ordering:
- free_irq() FIRST to synchronize with running IRQ handlers and prevent them from scheduling new tasklets
- Then kill tasklets to wait for already-scheduled ones to complete
- Only then free other resources
--- drivers/dma/at_hdmac.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-)
drivers/dma/at_hdmac.c +19 -9
@@ -1930,6 +1930,20 @@ static void at_dma_off(struct at_dma *atdma)cpu_relax (); } +static void at_dma_cleanup_channels (struct at_dma *atdma) +{ +struct dma_chan *chan, *_chan; +int i =0 ; + +list_for_each_entry_safe (chan, _chan, &atdma->dma_device.channels, + device_node) { +/* Disable interrupts */ +atc_disable_chan_irq (atdma, i++); +tasklet_kill (&to_at_dma_chan (chan)->vc.task); +list_del (&chan->device_node); + } +} +static int __init at_dma_probe (struct platform_device *pdev) {struct at_dma *atdma;
@@ -2095,6 +2109,8 @@ static int __init at_dma_probe(struct platform_device *pdev) err_of_dma_controller_register:dma_async_device_unregister (&atdma->dma_device); err_dma_async_device_register: +disable_irq (platform_get_irq (pdev,0 )); +at_dma_cleanup_channels (atdma);dma_pool_destroy (atdma->memset_pool); err_memset_pool_create:dma_pool_destroy (atdma->lli_pool);
@@ -2108,23 +2124,17 @@ static int __init at_dma_probe(struct platform_device *pdev)static int at_dma_remove (struct platform_device *pdev) {struct at_dma *atdma =platform_get_drvdata (pdev); -struct dma_chan *chan, *_chan;at_dma_off (atdma);if (pdev->dev.of_node)of_dma_controller_free (pdev->dev.of_node);dma_async_device_unregister (&atdma->dma_device); -dma_pool_destroy (atdma->memset_pool); -dma_pool_destroy (atdma->lli_pool);free_irq (platform_get_irq (pdev,0 ), atdma); -list_for_each_entry_safe (chan, _chan, &atdma->dma_device.channels, - device_node) { -/* Disable interrupts */ -atc_disable_chan_irq (atdma, chan->chan_id); -list_del (&chan->device_node); - } +at_dma_cleanup_channels (atdma); +dma_pool_destroy (atdma->memset_pool); +dma_pool_destroy (atdma->lli_pool);clk_disable_unprepare (atdma->clk);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2092/3318 dmaengine: mediatek: hsdma: fix runtime PM leak on init failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit f10d96b1c549a2f43506e9bf847196839808b8dc ]
mtk_hsdma_hw_init() enables runtime PM and gets a runtime PM reference before enabling the HSDMA clock. It currently ignores failures from pm_runtime_get_sync(); if runtime resume fails, the usage count remains held. If clk_prepare_enable() then fails, the usage count remains held.
Use devm_pm_runtime_enable() to manage runtime PM enablement, and use pm_runtime_resume_and_get() so resume failures do not leak the usage count. If clk_prepare_enable() fails after a successful runtime resume, drop the runtime PM reference before returning.
The probe path also ignores the return value from mtk_hsdma_hw_init(), so a failed hardware init can continue as a successful probe. Propagate mtk_hsdma_hw_init() failures from probe, while keeping a separate unwind label so mtk_hsdma_hw_deinit() is only called after hardware init succeeds.
--- drivers/dma/mediatek/mtk-hsdma.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-)
drivers/dma/mediatek/mtk-hsdma.c +19 -7
@@ -848,17 +848,27 @@ static int mtk_hsdma_hw_init(struct mtk_hsdma_device *hsdma) {int err; -pm_runtime_enable (hsdma2dev (hsdma)); -pm_runtime_get_sync (hsdma2dev (hsdma)); + err =devm_pm_runtime_enable (hsdma2dev (hsdma)); +if (err) +return err; + + err =pm_runtime_resume_and_get (hsdma2dev (hsdma)); +if (err <0 ) +return err; err =clk_prepare_enable (hsdma->clk);if (err) -return err; + goto err_put_pm;mtk_dma_write (hsdma,MTK_HSDMA_INT_ENABLE ,0 );mtk_dma_write (hsdma,MTK_HSDMA_GLO ,MTK_HSDMA_GLO_DEFAULT );return 0 ; + +err_put_pm: +pm_runtime_put_sync (hsdma2dev (hsdma)); + +return err; }static int mtk_hsdma_hw_deinit (struct mtk_hsdma_device *hsdma)
@@ -868,7 +878,6 @@ static int mtk_hsdma_hw_deinit(struct mtk_hsdma_device *hsdma)clk_disable_unprepare (hsdma->clk);pm_runtime_put_sync (hsdma2dev (hsdma)); -pm_runtime_disable (hsdma2dev (hsdma));return 0 ; }
@@ -983,7 +992,9 @@ static int mtk_hsdma_probe(struct platform_device *pdev) goto err_unregister; } -mtk_hsdma_hw_init (hsdma); + err =mtk_hsdma_hw_init (hsdma); +if (err) + goto err_free; err = devm_request_irq(&pdev->dev, hsdma->irq, mtk_hsdma_irq, 0,
@@ -991,7 +1002,7 @@ static int mtk_hsdma_probe(struct platform_device *pdev)if (err) {dev_err (&pdev->dev,"request_irq failed with err %d\n" , err); - goto err_free; + goto err_deinit; }platform_set_drvdata (pdev, hsdma);
@@ -1000,8 +1011,9 @@ static int mtk_hsdma_probe(struct platform_device *pdev)return 0 ; -err_free: +err_deinit:mtk_hsdma_hw_deinit (hsdma); +err_free:of_dma_controller_free (pdev->dev.of_node); err_unregister:dma_async_device_unregister (dd);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2093/3318 dmaengine: img-mdc: Fix runtime PM usage counter leak
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 4a1a2d8b8529cc569b769b92fcd71c53805cbeb2 ]
pm_runtime_get_sync() leaves the IMG MDC device's usage counter incremented when runtime resume fails. mdc_alloc_chan_resources() returns that error to the DMA core, so the channel's client count is not incremented and mdc_free_chan_resources() is not called to drop the reference. Repeated allocation attempts can therefore accumulate usage references and prevent runtime suspend.
Use pm_runtime_resume_and_get() so a failed resume does not retain a usage reference while successful allocations remain paired with mdc_free_chan_resources(). DMA core only treats negative return values as allocation failures, so the helper's zero success return preserves behavior.
This issue was found by a static analysis checker and confirmed by manual source review.
--- drivers/dma/img-mdc-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/img-mdc-dma.c +1 -1
@@ -738,7 +738,7 @@ static int mdc_alloc_chan_resources(struct dma_chan *chan)struct mdc_chan *mchan =to_mdc_chan (chan);struct device *dev =mdma2dev (mchan->mdma); -return pm_runtime_get_sync (dev); +return pm_runtime_resume_and_get (dev); }static void mdc_free_chan_resources (struct dma_chan *chan)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2094/3318 dmaengine: zynqmp_dma: Add support for AMD Versal Gen 2 DMA IP
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abin Joseph <[email protected]>
[ Upstream commit 13113f750a4ae0b1770fa25dc94852977ebfb942 ]
ZynqMP DMA IP and AMD Versal Gen 2 DMA IP are similar but have different interrupt register offset. Create a dedicated compatible string to support Versal Gen 2 DMA IP with Irq register offset for interrupt Enable/Disable/Status/Mask functionality.
Stable-dep-of: 0266dac57019 ("dmaengine: zynqmp_dma: Fix chan probe/remove error handling")
--- drivers/dma/xilinx/zynqmp_dma.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)
drivers/dma/xilinx/zynqmp_dma.c +23 -4
@@ -22,10 +22,10 @@#include "../dmaengine.h" /* Register Offsets */ -#define ZYNQMP_DMA_ISR 0x100 -#define ZYNQMP_DMA_IMR 0x104 -#define ZYNQMP_DMA_IER 0x108 -#define ZYNQMP_DMA_IDS 0x10C +#define ZYNQMP_DMA_ISR (chan->irq_offset + 0x100) +#define ZYNQMP_DMA_IMR (chan->irq_offset + 0x104) +#define ZYNQMP_DMA_IER (chan->irq_offset + 0x108) +#define ZYNQMP_DMA_IDS (chan->irq_offset + 0x10c)#define ZYNQMP_DMA_CTRL0 0x110#define ZYNQMP_DMA_CTRL1 0x114#define ZYNQMP_DMA_DATA_ATTR 0x120
@@ -145,6 +145,9 @@#define tx_to_desc (tx) container_of(tx, struct zynqmp_dma_desc_sw, \ async_tx) +/* IRQ Register offset for Versal Gen 2 */ +#define IRQ_REG_OFFSET 0x308 +/** * struct zynqmp_dma_desc_ll - Hw linked list descriptor * @addr: Buffer address
@@ -211,6 +214,7 @@ struct zynqmp_dma_desc_sw {* @bus_width: Bus width * @src_burst_len: Source burst length * @dst_burst_len: Dest burst length +* @irq_offset: Irq register offset */ struct zynqmp_dma_chan {struct zynqmp_dma_device *zdev;
@@ -235,6 +239,7 @@ struct zynqmp_dma_chan {u32 bus_width;u32 src_burst_len;u32 dst_burst_len; +u32 irq_offset; };/**
@@ -253,6 +258,14 @@ struct zynqmp_dma_device {struct clk *clk_apb; }; +struct zynqmp_dma_config { +u32 offset; +}; + +static const struct zynqmp_dma_config versal2_dma_config = { + .offset =IRQ_REG_OFFSET , +}; +static inline void zynqmp_dma_writeq (struct zynqmp_dma_chan *chan,u32 reg,u64 value) {
@@ -892,6 +905,7 @@ static int zynqmp_dma_chan_probe(struct zynqmp_dma_device *zdev, {struct zynqmp_dma_chan *chan;struct device_node *node = pdev->dev.of_node; +const struct zynqmp_dma_config *match_data;int err; chan =devm_kzalloc (zdev->dev,sizeof (*chan),GFP_KERNEL );
@@ -919,6 +933,10 @@ static int zynqmp_dma_chan_probe(struct zynqmp_dma_device *zdev,return -EINVAL ; } + match_data =of_device_get_match_data (&pdev->dev); +if (match_data) + chan->irq_offset = match_data->offset; + chan->is_dmacoherent =of_property_read_bool (node,"dma-coherent" ); zdev->chan = chan;tasklet_setup (&chan->tasklet, zynqmp_dma_do_tasklet);
@@ -1163,6 +1181,7 @@ static int zynqmp_dma_remove(struct platform_device *pdev) }static const struct of_device_id zynqmp_dma_of_match[] = { + { .compatible ="amd,versal2-dma-1.0" , .data = &versal2_dma_config }, { .compatible ="xlnx,zynqmp-dma-1.0" , }, {} };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2095/3318 dmaengine: zynqmp_dma: Fix chan probe/remove error handling
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Golla Nagendra <[email protected]>
[ Upstream commit 0266dac57019201a14a81245d22750ab221d6c66 ]
Keep the real platform_get_irq() error by returning ret directly, stage IRQ setup via a local ret variable, and assign chan->irq only after devm_request_irq() succeeds.
Initialize chan->irq to -1 and initialize chan->common.device_node before it may be touched by teardown. In channel remove, free IRQ only for valid IRQ numbers and delete the channel node only when it is linked.
Register the channel node only after successful IRQ setup. On channel probe failure in zynqmp_dma_probe(), route cleanup through the existing free_chan_resources teardown path.
--- drivers/dma/xilinx/zynqmp_dma.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-)
drivers/dma/xilinx/zynqmp_dma.c +17 -11
@@ -205,7 +205,7 @@ struct zynqmp_dma_desc_sw {* @desc_pool_p: Physical allocated descriptor base * @desc_free_cnt: Descriptor available count * @dev: The dma device -* @irq: Channel IRQ +* @irq: Linux IRQ number, or -1 when not registered * @is_dmacoherent: Tells whether dma operations are coherent or not * @tasklet: Cleanup work after irq * @idle : Channel status;
@@ -887,10 +887,11 @@ static void zynqmp_dma_chan_remove(struct zynqmp_dma_chan *chan)if (!chan)return ; -if (chan->irq) +if (chan->irq >=0 )devm_free_irq (chan->zdev->dev, chan->irq, chan);tasklet_kill (&chan->tasklet); -list_del (&chan->common.device_node); +if (!list_empty (&chan->common.device_node)) +list_del (&chan->common.device_node); }/**
@@ -906,13 +907,14 @@ static int zynqmp_dma_chan_probe(struct zynqmp_dma_device *zdev,struct zynqmp_dma_chan *chan;struct device_node *node = pdev->dev.of_node;const struct zynqmp_dma_config *match_data; -int err; +int err, ret; chan =devm_kzalloc (zdev->dev,sizeof (*chan),GFP_KERNEL );if (!chan)return -ENOMEM ; chan->dev = zdev->dev; chan->zdev = zdev; + chan->irq =-1 ; chan->regs =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (chan->regs))
@@ -945,22 +947,26 @@ static int zynqmp_dma_chan_probe(struct zynqmp_dma_device *zdev,INIT_LIST_HEAD (&chan->pending_list);INIT_LIST_HEAD (&chan->done_list);INIT_LIST_HEAD (&chan->free_list); +INIT_LIST_HEAD (&chan->common.device_node);dma_cookie_init (&chan->common); chan->common.device = &zdev->common; -list_add_tail (&chan->common.device_node, &zdev->common.channels); -zynqmp_dma_init (chan); - chan->irq =platform_get_irq (pdev,0 ); -if (chan->irq <0 ) -return -ENXIO ; - err =devm_request_irq (&pdev->dev, chan->irq, zynqmp_dma_irq_handler,0 , + ret =platform_get_irq (pdev,0 ); +if (ret <0 ) +return ret; + + err =devm_request_irq (&pdev->dev, ret, zynqmp_dma_irq_handler,0 ,"zynqmp-dma" , chan);if (err)return err; + chan->irq = ret; + chan->desc_size =sizeof (struct zynqmp_dma_desc_ll ); chan->idle = true; +list_add_tail (&chan->common.device_node, &zdev->common.channels); +return 0 ; }
@@ -1125,7 +1131,7 @@ static int zynqmp_dma_probe(struct platform_device *pdev) ret =zynqmp_dma_chan_probe (zdev, pdev);if (ret) {dev_err_probe (&pdev->dev, ret,"Probing channel failed\n" ); - goto err_disable_pm; + goto free_chan_resources; } p->dst_addr_widths =BIT (zdev->chan->bus_width /8 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2096/3318 dmaengine: dw-axi-dmac: convert clock handling to clk_bulk API
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chaithanya Lagisetty <[email protected]>
[ Upstream commit c843417e6d6b55e24318e2edf405566e70786d3b ]
The driver managed its two mandatory clocks (core-clk and cfgr-clk) individually. This was error prone: axi_dma_resume() enabled cfgr_clk and then core_clk, and if enabling core_clk failed it returned the error without disabling cfgr_clk, leaving the clock refcount unbalanced.
Convert the driver to the clk_bulk API. The two clocks are always acquired, enabled and disabled together, so a clk_bulk_data array expresses this naturally and shrinks the get/enable/disable paths. clk_bulk_prepare_enable() also unwinds any clock it already enabled when a later one fails, which fixes the resume imbalance.
--- .../dma/dw-axi-dmac/dw-axi-dmac-platform.c | 28 ++++++++----------- drivers/dma/dw-axi-dmac/dw-axi-dmac.h | 3 +- 2 files changed, 13 insertions(+), 18 deletions(-)
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +12 -16
@@ -1248,8 +1248,7 @@ static int axi_dma_suspend(struct axi_dma_chip *chip)axi_dma_irq_disable (chip);axi_dma_disable (chip); -clk_disable_unprepare (chip->core_clk); -clk_disable_unprepare (chip->cfgr_clk); +clk_bulk_disable_unprepare (ARRAY_SIZE (chip->clks), chip->clks);return 0 ; }
@@ -1258,11 +1257,7 @@ static int axi_dma_resume(struct axi_dma_chip *chip) {int ret; - ret =clk_prepare_enable (chip->cfgr_clk); -if (ret <0 ) -return ret; - - ret =clk_prepare_enable (chip->core_clk); + ret =clk_bulk_prepare_enable (ARRAY_SIZE (chip->clks), chip->clks);if (ret <0 )return ret;
@@ -1425,13 +1420,11 @@ static int dw_probe(struct platform_device *pdev) chip->dw->hdata->use_cfg2 = !!(flags &AXI_DMA_FLAG_USE_CFG2 ); - chip->core_clk =devm_clk_get (chip->dev,"core-clk" ); -if (IS_ERR (chip->core_clk)) -return PTR_ERR (chip->core_clk); - - chip->cfgr_clk =devm_clk_get (chip->dev,"cfgr-clk" ); -if (IS_ERR (chip->cfgr_clk)) -return PTR_ERR (chip->cfgr_clk); + chip->clks[0 ].id ="core-clk" ; + chip->clks[1 ].id ="cfgr-clk" ; + ret =devm_clk_bulk_get (chip->dev,ARRAY_SIZE (chip->clks), chip->clks); +if (ret) +return dev_err_probe (chip->dev, ret,"failed to get clocks\n" ); ret =parse_device_properties (chip);if (ret)
@@ -1542,10 +1535,13 @@ static int dw_remove(struct platform_device *pdev)struct dw_axi_dma *dw = chip->dw;struct axi_dma_chan *chan, *_chan;u32 i; +int ret;/* Enable clk before accessing to registers */ -clk_prepare_enable (chip->cfgr_clk); -clk_prepare_enable (chip->core_clk); + ret =clk_bulk_prepare_enable (ARRAY_SIZE (chip->clks), chip->clks); +if (ret) +dev_warn (chip->dev,"failed to enable clocks before remove: %d\n" , + ret);axi_dma_irq_disable (chip);for (i =0 ; i < dw->hdata->nr_channels; i++) {axi_chan_disable (&chip->dw->chan[i]);
drivers/dma/dw-axi-dmac/dw-axi-dmac.h +1 -2
@@ -68,8 +68,7 @@ struct axi_dma_chip {int irq;void __iomem *regs;void __iomem *apb_regs; -struct clk *core_clk; -struct clk *cfgr_clk; +struct clk_bulk_data clks[2 ];struct dw_axi_dma *dw; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2097/3318 dmaengine: xilinx_dma: Fix MCDMA descriptor fields based on DMA direction
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Neeli <[email protected]>
[ Upstream commit b70ab341088b2114dcbc7be868588f3e97893e6a ]
The MCDMA BD format differs between memory-to-device (MM2S) and device-to-memory (S2MM) directions, but the driver was using generic 'status' and 'sideband_status' fields for both. This led to incorrect residue calculations when the hardware updates direction-specific fields.
Refactor the descriptor structure to use unions with direction-specific field mappings, and update the residue calculation logic to select the correct status field based on DMA direction.
This matches the hardware descriptor layout and fixes incorrect residue reporting.
--- drivers/dma/xilinx/xilinx_dma.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-)
drivers/dma/xilinx/xilinx_dma.c +19 -7
@@ -220,6 +220,7 @@#define XILINX_MCDMA_IRQ_ERR_MASK BIT(7)#define XILINX_MCDMA_BD_EOP BIT(30)#define XILINX_MCDMA_BD_SOP BIT(31) +#define XILINX_MCDMA_BD_HW_SIZE 64/** * struct xilinx_vdma_desc_hw - Hardware Descriptor
@@ -274,8 +275,10 @@ struct xilinx_axidma_desc_hw {* @buf_addr_msb: MSB of Buffer address @0x0C * @rsvd: Reserved field @0x10 * @control: Control Information field @0x14 -* @status: Status field @0x18 -* @sideband_status: Status of sideband signals @0x1C +* @mm2s_ctrl_sideband: Sideband control info for mm2s @0x18 +* @s2mm_status: Status field for s2mm @0x18 +* @mm2s_status: Status field for mm2s @0x1C +* @s2mm_sideband_status: Sideband status for s2mm @0x1C * @app: APP Fields @0x20 - 0x30 */ struct xilinx_aximcdma_desc_hw {
@@ -285,10 +288,17 @@ struct xilinx_aximcdma_desc_hw {u32 buf_addr_msb;u32 rsvd;u32 control; -u32 status; -u32 sideband_status; +union { +u32 mm2s_ctrl_sideband; +u32 s2mm_status; + }; +union { +u32 mm2s_status; +u32 s2mm_sideband_status; + };u32 app[XILINX_DMA_NUM_APP_WORDS ]; }__aligned(64) ; +static_assert (sizeof (struct xilinx_aximcdma_desc_hw ) ==XILINX_MCDMA_BD_HW_SIZE );/** * struct xilinx_cdma_desc_hw - Hardware Descriptor
@@ -1022,9 +1032,11 @@ static u32 xilinx_dma_get_residue(struct xilinx_dma_chan *chan, struct xilinx_aximcdma_tx_segment, node); aximcdma_hw = &aximcdma_seg->hw; - residue += - (aximcdma_hw->control & chan->xdev->max_buffer_len) - - (aximcdma_hw->status & chan->xdev->max_buffer_len); + residue += aximcdma_hw->control & chan->xdev->max_buffer_len; +if (chan->direction ==DMA_DEV_TO_MEM ) + residue -= aximcdma_hw->s2mm_status & chan->xdev->max_buffer_len; +else + residue -= aximcdma_hw->mm2s_status & chan->xdev->max_buffer_len; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2098/3318 dmaengine: xilinx_dma: Move descriptors to done list based on completion bit
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Neeli <[email protected]>
[ Upstream commit 5b585cc8778185ae7a7c9903f8cd70d562b91282 ]
In AXI MCDMA, xilinx_dma_complete_descriptor() walks the channel's active_list and unconditionally moves every entry to the done_list. The MCDMA IOC interrupt handler invokes this function on every interrupt-on-completion, but with interrupt coalescing (IRQThreshold > 1) an IOC interrupt may fire after only a subset of the queued descriptors have actually been processed by the hardware. As a result, descriptors whose completion bit is not yet set in the BD status were being reported as completed to client drivers.
Add a check for the descriptor completion bit before moving entries from the active list to the done list, using the appropriate direction- specific status field (s2mm_status for DMA_DEV_TO_MEM, mm2s_status for DMA_MEM_TO_DEV).
This mirrors the AXIDMA fix in commit 7bcdaa658102 ("dmaengine:xilinx_dma: Freeup active list based on descriptor completion bit").
--- drivers/dma/xilinx/xilinx_dma.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/dma/xilinx/xilinx_dma.c +11 -0
@@ -1765,6 +1765,17 @@ static void xilinx_dma_complete_descriptor(struct xilinx_dma_chan *chan) struct xilinx_axidma_tx_segment, node);if (!(seg->hw.status &XILINX_DMA_BD_COMP_MASK ) && chan->has_sg)break ; + }else if (chan->xdev->dma_config->dmatype ==XDMA_TYPE_AXIMCDMA ) { +struct xilinx_aximcdma_tx_segment *seg; +u32 status; + + seg =list_last_entry (&desc->segments, + struct xilinx_aximcdma_tx_segment, + node); + status = (chan->direction ==DMA_DEV_TO_MEM ) ? + seg->hw.s2mm_status : seg->hw.mm2s_status; +if (!(status &XILINX_DMA_BD_COMP_MASK )) +break ; }if (chan->has_sg && chan->xdev->dma_config->dmatype !=XDMA_TYPE_VDMA )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2099/3318 dmaengine: zynqmp_dma: drop redundant label
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vinod Koul <[email protected]>
[ Upstream commit 08f04d5ab868bc28d3115f7406499e8e5d1d1765 ]
Commit 3f30db282c28 ("dmaengine: zynqmp_dma: Fix chan probe/remove error handling") dropped the use of err_disable_pm label causing warning:
drivers/dma/xilinx/zynqmp_dma.c: In function ‘zynqmp_dma_probe’:drivers/dma/xilinx/zynqmp_dma.c:1171:1: error: label ‘err_disable_pm’ defined but not used [-Werror=unused-label]
1171 | err_disable_pm:
Drop it
--- drivers/dma/xilinx/zynqmp_dma.c | 1 - 1 file changed, 1 deletion(-)
drivers/dma/xilinx/zynqmp_dma.c +0 -1
@@ -1158,7 +1158,6 @@ static int zynqmp_dma_probe(struct platform_device *pdev) free_chan_resources:zynqmp_dma_chan_remove (zdev->chan); -err_disable_pm:if (!pm_runtime_enabled (zdev->dev))zynqmp_dma_runtime_suspend (zdev->dev);pm_runtime_disable (zdev->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2100/3318 ACPI: button: Add lid_init_state quirk for Razer Blade Stealth 13 (Early 2020) RZ09-0310
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Gallagher <[email protected]>
[ Upstream commit f16c512a07b954aa3b0b3c580e7abb5dd4f5e703 ]
This patch adds a quirk mapping for the "Blade Stealth 13 (Early 2020) - RZ09-0310" laptop, which exhibits the same issue as the following two related products already accounted for in this file.
- Razer Blade Stealth 13 Late 2019
- Blade Pro 17 (Early 2020) - RZ09-0329
Summary of the issue this fixes:
The firmware's _LID method still returns "closed" after resume when the lid was opened during S3, causing systemd-logind to suspend the system again within several seconds (15-40) after waking.
--- drivers/acpi/button.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/acpi/button.c +12 -0
@@ -141,6 +141,18 @@ static const struct dmi_system_id dmi_lid_quirks[] = { }, .driver_data = (void *)(long)ACPI_BUTTON_LID_INIT_OPEN, }, + { +/* +* Razer Blade Stealth 13 early 2020, when the lid is opened +* while suspended the open notification is lost and _LID keeps +* returning closed after resume, causing spurious re-suspends. +*/ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Razer" ), + DMI_MATCH(DMI_PRODUCT_NAME, "Blade Stealth 13 (Early 2020) - RZ09-0310"), + }, + .driver_data = (void *)(long)ACPI_BUTTON_LID_INIT_OPEN, + }, {/* * Samsung galaxybook2 ,initial _LID device notification returns
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2101/3318 ACPI: PM: Drop parent state update from acpi_device_get_power()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit 5636eebb7bb1c6f06f0058d48353686304d4bb47 ]
The parent state update in acpi_device_get_power(), that occurs when the child device turns out to be in D0 and the parent's power state is still unknown, is highly questionable because it may cause the reference counters of the power resources used by the parent in D0 (if any) to underflow when the parent goes into a low-power state later. Moreover, there is no reason to do it on reads from the real_power_state sysfs attribute of the child.
That check had been added by commit 8f7412a792bc ("ACPI / PM: Infer parent power state from child if unknown, v2") before starting to handle the "missing _PSC and no power resources" case directly in acpi_bus_init_power(), as of commit b3785492268f ("ACPI / PM: Do not power manage devices in unknown initial states"). It is not necessary any more and commit b3785492268f should have removed it.
Drop it now.
--- drivers/acpi/device_pm.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-)
drivers/acpi/device_pm.c +2 -13
@@ -75,15 +75,14 @@ static int acpi_dev_pm_explicit_get(struct acpi_device *device, int *state)int acpi_device_get_power (struct acpi_device *device,int *state) {int result =ACPI_STATE_UNKNOWN ; -struct acpi_device *parent;int error;if (!device || !state)return -EINVAL ; - parent =acpi_dev_parent (device); -if (!device->flags.power_manageable) { +struct acpi_device *parent =acpi_dev_parent (device); +/* TBD: Non-recursive algorithm for walking up hierarchy. */ *state = parent ? parent->power.state :ACPI_STATE_D0 ; goto out;
@@ -119,16 +118,6 @@ int acpi_device_get_power(struct acpi_device *device, int *state) result = psc >ACPI_STATE_D2 ?ACPI_STATE_D3_HOT : psc; } -/* -* If we were unsure about the device parent's power state up to this -* point, the fact that the device is in D0 implies that the parent has -* to be in D0 too, except if ignore_parent is set. -*/ -if (!device->power.flags.ignore_parent && parent && - parent->power.state ==ACPI_STATE_UNKNOWN && - result ==ACPI_STATE_D0 ) - parent->power.state =ACPI_STATE_D0 ; - *state = result; out:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2102/3318 ACPI: PCI: Introduce acpi_dev_get_pci_dev()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit 9d4f0ecb87fd939207682ec30dcaf128d43f07fb ]
Some acpi_get_pci_dev() callers already have a struct ACPI device for which they want to get the struct pci_dev pointer of the associated PCI device, so they don't need to look for one.
For this reason, add acpi_dev_get_pci_dev() that will get a PCI device for a given ACPI one (if possible) and turn acpi_get_pci_dev() into a static inline helper passing the acpi_fetch_acpi_dev() return value directly to acpi_dev_get_pci_dev().
No intentional functional impact.
Stable-dep-of: 2f4ddf2bd1ba ("ACPI: scan: Stop calling acpi_bus_init_power() early")
--- drivers/acpi/pci_root.c | 22 +++++++++++----------- include/acpi/acpi_drivers.h | 9 +++++++-- 2 files changed, 18 insertions(+), 13 deletions(-)
drivers/acpi/pci_root.c +11 -11
@@ -299,20 +299,20 @@ struct acpi_handle_node { };/** -* acpi_get_pci_dev - convert ACPI CA handle to struct pci_dev -* @handle: the handle in question +* acpi_dev_get_pci_dev - Get a struct pci_dev for a given ACPI device +* @adev: Target ACPI device. * -* Given an ACPI CA handle, the desired PCI device is located in the -* list of PCI devices. +* Find the PCI device associated with @adev, if any, and bump up its reference +* counter. * -* If the device is found, its reference count is increased and this -* function returns a pointer to its data structure. The caller must -* decrement the reference count by calling pci_dev_put(). -* If no device is found, %NULL is returned. +* Callers are responsible for dropping the PCI device reference obtained by +* this function. +* +* Return: The struct pci_dev pointer of a reference-counted PCI device on +* success or NULL on failure. */ -struct pci_dev *acpi_get_pci_dev (acpi_handle handle) +struct pci_dev *acpi_dev_get_pci_dev (struct acpi_device *adev) { -struct acpi_device *adev =acpi_fetch_acpi_dev (handle);struct acpi_device_physical_node *pn;struct pci_dev *pci_dev =NULL ;
@@ -333,7 +333,7 @@ struct pci_dev *acpi_get_pci_dev(acpi_handle handle)return pci_dev; } -EXPORT_SYMBOL_GPL (acpi_get_pci_dev); +EXPORT_SYMBOL_GPL (acpi_dev_get_pci_dev);/** * acpi_pci_osc_control_set - Request control of PCI root _OSC features.
include/acpi/acpi_drivers.h +7 -2
@@ -59,14 +59,19 @@ int acpi_pci_link_free_irq(acpi_handle handle);struct pci_bus ;#ifdef CONFIG_PCI -struct pci_dev *acpi_get_pci_dev (acpi_handle ); +struct pci_dev *acpi_dev_get_pci_dev (struct acpi_device *adev);#else -static inline struct pci_dev *acpi_get_pci_dev (acpi_handle handle) +static inline struct pci_dev *acpi_dev_get_pci_dev (struct acpi_device *adev) {return NULL ; }#endif +static inline struct pci_dev *acpi_get_pci_dev (acpi_handle handle) +{ +return acpi_dev_get_pci_dev (acpi_fetch_acpi_dev (handle)); +} +/* Arch-defined function to add a bus to the system */ struct pci_bus *pci_acpi_scan_root (struct acpi_pci_root *root);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2103/3318 ACPI: scan: Stop calling acpi_bus_init_power() early
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit 2f4ddf2bd1baf0ee3c8542ec6f382a3585cae607 ]
There is a problem, introduced by commit 9d9bcae47fd5 ("ACPI: delay enumeration of devices with a _DEP pointing to an INT3472 device") inadvertently, that devices with missing dependencies may be put into power state D0 prematurely [1].
Namely, acpi_bus_init_power() called by acpi_bus_get_power_flags() during the early initialization of ACPI device objects, may discover that all of the power resources needed by the given device to be in power state D0 are initially on, so it will reference count those power resources and transition the device into D0. Later, if acpi_bus_attach() running for that device notices that it has missing dependencies, the enumeration of it will be deferred and its power_manageable flag will be cleared, even though it is still in D0 at that point.
After the dependencies in question have been met, acpi_bus_attach() runs again for the device and now it calls acpi_bus_init_power() that takes additional references to the power resources used by the device in D0. These additional references prevent the power resources from being turned off when the device goes into D3hot/D3cold.
Another problem, related to the previous one, is that ACPI power state initialization may be carried out for devices whose parents are not ready for enumeration which may lead to initialization ordering issues.
To address both, stop calling acpi_bus_init_power() from acpi_bus_get_power_flags(), but also take the initialization of PCI devices into account, which needs to be done because they are initialized and bound to their ACPI companions before acpi_bus_attach() is called for the latter.
To that end, notice that acpi_power_up_if_adr_present() is used for powering-up PCI devices in D3cold before walking the bus in order to discover them and the initial ACPI power state of those devices needs to be known for this purpose, so add an acpi_bus_init_power() invocation to that function. [The debug statement printed by it duplicates the debug statements printed during the acpi_bus_init_power() execution, so drop it.]
Moreover, since the ACPI companions of PCI devices are associated with the corresponding PCI devices found on the bus before acpi_bus_attach() is called for them, it is not necessary or even useful to skip them in acpi_bus_attach() due to an ACPI status mismatch, so avoid doing that and complain if the ACPI status does not match the observed situation.
Also use the ACPI power state tracking to decide whether or not the device's power state needs to be initialized in acpi_bus_attach() instead of using the "initialized" flag of the ACPI device object for this purpose, which is fragile and inconvenient, and clear the power_manageable flag on failure in acpi_bus_init_power() (additionally, poison the device ACPI power state as "invalid" if the initialization of it fails). That allows the clearing of the power_manageable flag for devices with unmet dependencies to be dropped.
While at it, add a debug message pringing statement to acpi_bus_init_power() to facilitate diagnostics.
--- drivers/acpi/device_pm.c | 62 ++++++++++++++++++++++++++++++++-------- drivers/acpi/scan.c | 40 +++++++++++++++++--------- 2 files changed, 76 insertions(+), 26 deletions(-)
drivers/acpi/device_pm.c +50 -12
@@ -23,6 +23,8 @@#include "fan.h" #include "internal.h" +#define ACPI_D_STATE_INVALID ACPI_D_STATE_COUNT +/** * acpi_power_state_string - String representation of ACPI device power state. * @state: ACPI device power state to return the string representation of.
@@ -293,24 +295,28 @@ int acpi_bus_set_power(acpi_handle handle, int state) }EXPORT_SYMBOL (acpi_bus_set_power); -int acpi_bus_init_power (struct acpi_device *device) +static int acpi_device_init_power (struct acpi_device *device) {int state;int result; -if (!device) -return -EINVAL ; - - device->power.state =ACPI_STATE_UNKNOWN ; -if (!acpi_device_is_present (device)) { - device->flags.initialized = false; -return -ENXIO ; - } - result =acpi_device_get_power (device, &state);if (result)return result; +/* +* If the current power state of the device is D0 and it has a parent +* whose power state is not ignored, and the parent's power state +* initialization has failed, the parent's power state can be updated to +* D0 for consistency. +*/ +if (!device->power.flags.ignore_parent && state ==ACPI_STATE_D0 ) { +struct acpi_device *parent =acpi_dev_parent (device); + +if (parent && parent->power.state ==ACPI_D_STATE_INVALID ) + parent->power.state =ACPI_STATE_D0 ; + } +if (state <ACPI_STATE_D3_COLD && device->power.flags.power_resources) {/* Reference count the power resources. */ result =acpi_power_on_resources (device, state);
@@ -340,9 +346,36 @@ int acpi_bus_init_power(struct acpi_device *device) state =ACPI_STATE_D0 ; } device->power.state = state; + +acpi_handle_debug (device->handle,"Initial power state: %s\n" , +acpi_power_state_string (state)); +return 0 ; } +int acpi_bus_init_power (struct acpi_device *device) +{ +int result; + +if (device->power.state !=ACPI_STATE_UNKNOWN ) +return 0 ; + +/* +* The ACPI device power state can be only initialized once. If this +* fails, ACPI power management will not be used for the device going +* forward. +*/ + result =acpi_device_init_power (device); +if (result) { + device->flags.power_manageable =0 ; + device->power.state =ACPI_D_STATE_INVALID ; +acpi_handle_info (device->handle, +"Initial power state undetermined, ACPI PM disabled\n" ); + } + +return result; +} +/** * acpi_device_fix_up_power - Force device with missing _PSC into D0. * @device: Device object whose power state is to be fixed up.
@@ -464,8 +497,13 @@ static int acpi_power_up_if_adr_present(struct acpi_device *adev, void *not_usedif (!(adev->flags.power_manageable && adev->pnp.type.bus_address))return 0 ; -acpi_handle_debug (adev->handle,"Power state: %s\n" , -acpi_power_state_string (adev->power.state)); +/* +* This is done during the PCI root initialization which occurs before +* acpi_bus_attach() is called for the device, so the ACPI power state +* of the device needs to be initialized here. +*/ +if (acpi_bus_init_power (adev)) +return 0 ;if (adev->power.state ==ACPI_STATE_D3_COLD )return acpi_device_set_power (adev,ACPI_STATE_D0 );
drivers/acpi/scan.c +26 -14
@@ -17,6 +17,7 @@#include <linux/kthread.h> #include <linux/dmi.h> #include <linux/dma-map-ops.h> +#include <linux/pci.h> #include <linux/platform_data/x86/apple.h> #include <linux/pgtable.h> #include <linux/crc32.h>
@@ -1086,8 +1087,7 @@ static void acpi_bus_get_power_flags(struct acpi_device *device) device->power.states[ACPI_STATE_D3_COLD ].flags.valid =1 ; } -if (acpi_bus_init_power (device)) - device->flags.power_manageable =0 ; + device->power.state =ACPI_STATE_UNKNOWN ; }static void acpi_bus_get_flags (struct acpi_device *device)
@@ -2185,38 +2185,50 @@ static int acpi_scan_attach_handler(struct acpi_device *device)static int acpi_bus_attach (struct acpi_device *device,void *first_pass) {bool skip = !first_pass && device->flags.visited; +struct pci_dev *pci;acpi_handle ejd;int ret;if (skip) goto ok; + device->flags.initialized = true; +if (ACPI_SUCCESS (acpi_bus_get_ejd (device->handle, &ejd)))register_dock_dependent_device (device, ejd);acpi_bus_get_status (device); -/* Skip devices that are not ready for enumeration (e.g. not present) */ -if (!acpi_dev_ready_for_enumeration (device)) { - device->flags.initialized = false; +/* +* If the given ACPI device object has been already associated with a +* PCI device found on the bus, its status is effectively "present and +* enabled", and dependencies are not tracked for PCI devices, so it is +* not necessary or even useful to check the device's readiness in that +* case. +*/ + pci =acpi_dev_get_pci_dev (device); +if (pci) { +acpi_handle_debug (device->handle,"PCI companion %s found\n" , +pci_name (pci)); + +if (!acpi_device_is_present (device)) +pci_info (pci,FW_BUG "ACPI status differs from reality\n" ); + +pci_dev_put (pci); + }else if (!acpi_dev_ready_for_enumeration (device)) { +/* The device is not ready (e.g. not present), so skip it. */ acpi_device_clear_enumerated (device); - device->flags.power_manageable =0 ;return 0 ; } +if (device->handler) goto ok;acpi_ec_register_opregions (device); -if (!device->flags.initialized) { - device->flags.power_manageable = - device->power.states[ACPI_STATE_D0 ].flags.valid; -if (acpi_bus_init_power (device)) - device->flags.power_manageable =0 ; +acpi_bus_init_power (device); - device->flags.initialized = true; - }else if (device->flags.visited) { +if (device->flags.visited) goto ok; - } ret =acpi_scan_attach_handler (device);if (ret <0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2104/3318 ACPI: utils: Adjust message printing macros for ACPI objects
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit 78ddbfaa72d68acc98cd5ba12eca071d452702c4 ]
The majority of acpi_handle_<level>() macros use neither pr_fmt() nor dev_fmt() and acpi_handle_debug() uses pr_fmt() like dev_fmt(), but only if dynamic debug is compiled in.
For more consistency, redefine all of the macros in question to use dev_fmt() because they are more similar to the analogous dev_*() family of macros than to the pr_*() ones and make all of them use it in the same way.
While at it, rephrase the comment documenting those macros for more clarity.
--- include/linux/acpi.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
include/linux/acpi.h +12 -12
@@ -1202,34 +1202,34 @@ void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const c#endif /* -* acpi_handle_<level>: Print message with ACPI prefix and object path +* acpi_handle_<level> - Print a message with ACPI prefix and object path * -* These interfaces acquire the global namespace mutex to obtain an object -* path. In interrupt context, it shows the object path as <n/a>. +* In thread context, the global namespace mutex is acquired to obtain the +* object path. In interrupt context, the object path is shown as <n/a>. */ #define acpi_handle_emerg (handle, fmt, ...) \ - acpi_handle_printk(KERN_EMERG, handle, fmt, ##__VA_ARGS__) + acpi_handle_printk(KERN_EMERG, handle, dev_fmt(fmt), ##__VA_ARGS__)#define acpi_handle_alert (handle, fmt, ...) \ - acpi_handle_printk(KERN_ALERT, handle, fmt, ##__VA_ARGS__) + acpi_handle_printk(KERN_ALERT, handle, dev_fmt(fmt), ##__VA_ARGS__)#define acpi_handle_crit (handle, fmt, ...) \ - acpi_handle_printk(KERN_CRIT, handle, fmt, ##__VA_ARGS__) + acpi_handle_printk(KERN_CRIT, handle, dev_fmt(fmt), ##__VA_ARGS__)#define acpi_handle_err (handle, fmt, ...) \ - acpi_handle_printk(KERN_ERR, handle, fmt, ##__VA_ARGS__) + acpi_handle_printk(KERN_ERR, handle, dev_fmt(fmt), ##__VA_ARGS__)#define acpi_handle_warn (handle, fmt, ...) \ - acpi_handle_printk(KERN_WARNING, handle, fmt, ##__VA_ARGS__) + acpi_handle_printk(KERN_WARNING, handle, dev_fmt(fmt), ##__VA_ARGS__)#define acpi_handle_notice (handle, fmt, ...) \ - acpi_handle_printk(KERN_NOTICE, handle, fmt, ##__VA_ARGS__) + acpi_handle_printk(KERN_NOTICE, handle, dev_fmt(fmt), ##__VA_ARGS__)#define acpi_handle_info (handle, fmt, ...) \ - acpi_handle_printk(KERN_INFO, handle, fmt, ##__VA_ARGS__) + acpi_handle_printk(KERN_INFO, handle, dev_fmt(fmt), ##__VA_ARGS__)#if defined(DEBUG )#define acpi_handle_debug (handle, fmt, ...) \ - acpi_handle_printk(KERN_DEBUG, handle, fmt, ##__VA_ARGS__) + acpi_handle_printk(KERN_DEBUG, handle, dev_fmt(fmt), ##__VA_ARGS__)#else #if defined(CONFIG_DYNAMIC_DEBUG )#define acpi_handle_debug (handle, fmt, ...) \ _dynamic_func_call(fmt, __acpi_handle_debug, \ - handle, pr_fmt(fmt), ##__VA_ARGS__) + handle, dev_fmt(fmt), ##__VA_ARGS__)#else #define acpi_handle_debug (handle, fmt, ...) \ ({ \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2105/3318 wifi: ath11k: modify null check logic in ath11k_ce_rx_post_pipe()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Lobanov <[email protected]>
[ Upstream commit 52953d149ab4da0432d54b09f3c8add42b4d4a82 ]
The previous logic in ath11k_ce_rx_post_pipe() incorrectly required both dest_ring and status_ring to be NULL in order to exit the function. This caused the function to continue even if only one of the pointers was NULL, potentially leading to null pointer dereferences in ath11k_ce_rx_buf_enqueue_pipe().
Fix the condition by modifying the logic so that the function returns early if either dest_ring or status_ring is NULL.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/net/wireless/ath/ath11k/ce.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath11k/ce.c +1 -1
@@ -324,7 +324,7 @@ static int ath11k_ce_rx_post_pipe(struct ath11k_ce_pipe *pipe)dma_addr_t paddr;int ret =0 ; -if (!(pipe->dest_ring || pipe->status_ring)) +if (!pipe->dest_ring || !pipe->status_ring)return 0 ;spin_lock_bh (&ab->ce.ce_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2106/3318 wifi: ath11k: fix locking problem in ath11k_dp_rx_tid_del_func()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Escande <[email protected]>
[ Upstream commit c7555d47b1d051e0406474349deccf74b491ae01 ]
In this function, we iterate over dp->reo_cmd_cache_flush_list using list_for_each_entry_safe(), under dp->reo_cmd_lock for concurrent access, and for each expired entries we :
- drop the lock
- call ath11k_dp_reo_cache_flush()
- kfree() the entry
- retake the lock to keep on iterating
list_for_each_entry_safe() protects us from deleting the entry during iteration but doesn't protect for concurrent access. So another thread can take the lock and modify the list in between and crash like below.
To fix the issue, move all entries that needs to be freed to a local list while under the lock and then iterate over the list to free the entries without holding the lock.
BUG: Unable to handle kernel paging request at virtual address 00000010ddbeef8c Call trace: ath11k_dp_rx_tid_del_func+0x164/0x3c8 ath11k_dp_process_reo_status+0x1d4/0x2fc ath11k_dp_service_srng+0x334/0x338 ath11k_pcic_ext_grp_napi_poll+0x30/0xc0 __napi_poll+0x34/0x184 napi_threaded_poll+0xb4/0x1d8 kthread+0xdc/0xe0 ret_from_fork+0x10/0x20
Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.9.0.1-01977-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath11k/dp_rx.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/net/wireless/ath/ath11k/dp_rx.c +12 -7
@@ -762,6 +762,9 @@ static void ath11k_dp_rx_tid_del_func(struct ath11k_dp *dp, void *ctx,struct ath11k_base *ab = dp->ab;struct dp_rx_tid *rx_tid = ctx;struct dp_reo_cache_flush_elem *elem, *tmp; +struct list_head flush_list; + +INIT_LIST_HEAD (&flush_list);if (status ==HAL_REO_CMD_DRAIN ) { goto free_desc;
@@ -783,23 +786,25 @@ static void ath11k_dp_rx_tid_del_func(struct ath11k_dp *dp, void *ctx,list_add_tail (&elem->list, &dp->reo_cmd_cache_flush_list); dp->reo_cmd_cache_flush_count++; -/* Flush and invalidate aged REO desc from HW cache */ +/* identify aged REO desc that needs removal */ list_for_each_entry_safe (elem, tmp, &dp->reo_cmd_cache_flush_list, list) {if (dp->reo_cmd_cache_flush_count >DP_REO_DESC_FREE_THRESHOLD ||time_after (jiffies, elem->ts +msecs_to_jiffies (DP_REO_DESC_FREE_TIMEOUT_MS ))) { -list_del (&elem->list); +list_move_tail (&elem->list, &flush_list); dp->reo_cmd_cache_flush_count--; -spin_unlock_bh (&dp->reo_cmd_lock); - -ath11k_dp_reo_cache_flush (ab, &elem->data); -kfree (elem); -spin_lock_bh (&dp->reo_cmd_lock); } }spin_unlock_bh (&dp->reo_cmd_lock); +/* remove aged REO desc from HW */ +list_for_each_entry_safe (elem, tmp, &flush_list, list) { +ath11k_dp_reo_cache_flush (ab, &elem->data); +list_del (&elem->list); +kfree (elem); + } +return ; free_desc: dma_free_noncoherent(ab->dev, rx_tid->unaligned_size,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2107/3318 wifi: ath12k: Free allocated CE IRQs on request_irq() failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaradhana Sahu <[email protected]>
[ Upstream commit 12ca935af2e68447e9218a615ebbb5ff7faf1554 ]
When CE IRQ configuration fails, the driver does not release all IRQs that were successfully requested before the failure. This can leak IRQ resources during probe failure.
Free the previously requested CE IRQs before returning from the error path to ensure that partially initialized IRQ resources are properly cleaned up during probe failure.
Factor out the CE IRQ cleanup into a helper to reuse the cleanup logic during both error handling and driver teardown.
Also free CE IRQs when external IRQ configuration fails, before returning from the error path.
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.6-01243-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath12k/pci.c | 29 ++++++++++++++++++--------- 1 file changed, 19 insertions(+), 10 deletions(-)
drivers/net/wireless/ath/ath12k/pci.c +19 -10
@@ -329,6 +329,19 @@ static void ath12k_pci_sw_reset(struct ath12k_base *ab, bool power_on)ath12k_mhi_set_mhictrl_reset (ab); } +static void ath12k_pci_free_ce_irq (struct ath12k_base *ab,int num_ce) +{ +int i, irq_idx; + +for (i =0 ; i < num_ce; i++) { +if (ath12k_ce_get_attr_flags (ab, i) &CE_ATTR_DIS_INTR ) +continue ; + + irq_idx =ATH12K_PCI_IRQ_CE0_OFFSET + i; +free_irq (ab->irq_num[irq_idx], &ab->ce.ce_pipe[i]); + } +} +static void ath12k_pci_free_ext_irq (struct ath12k_base *ab) {int i, j;
@@ -345,15 +358,7 @@ static void ath12k_pci_free_ext_irq(struct ath12k_base *ab)static void ath12k_pci_free_irq (struct ath12k_base *ab) { -int i, irq_idx; - -for (i =0 ; i < ab->hw_params->ce_count; i++) { -if (ath12k_ce_get_attr_flags (ab, i) &CE_ATTR_DIS_INTR ) -continue ; - irq_idx =ATH12K_PCI_IRQ_CE0_OFFSET + i; -free_irq (ab->irq_num[irq_idx], &ab->ce.ce_pipe[i]); - } - +ath12k_pci_free_ce_irq (ab, ab->hw_params->ce_count);ath12k_pci_free_ext_irq (ab); }
@@ -614,6 +619,8 @@ static int ath12k_pci_config_irq(struct ath12k_base *ab)if (ret) {ath12k_err (ab,"failed to request irq %d: %d\n" , irq_idx, ret); + +ath12k_pci_free_ce_irq (ab, i);return ret; }
@@ -624,8 +631,10 @@ static int ath12k_pci_config_irq(struct ath12k_base *ab) } ret =ath12k_pci_ext_irq_config (ab); -if (ret) +if (ret) { +ath12k_pci_free_ce_irq (ab, ab->hw_params->ce_count);return ret; + }return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2108/3318 wifi: ath12k: refactor multiple MSI vector implementation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kang Yang <[email protected]>
[ Upstream commit 6711b2a80b9a9bf7d10042a526b1f92a5ba69362 ]
This is to prepare for one MSI vector support. IRQ enable and disable of CE and DP are done only in case of multiple MSI vectors.
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4
Stable-dep-of: 9a78703ec4a8 ("wifi: ath12k: Free allocated external IRQs on request_irq() failure")
--- drivers/net/wireless/ath/ath12k/pci.c | 48 ++++++++++++++++++++++----- drivers/net/wireless/ath/ath12k/pci.h | 2 ++ 2 files changed, 42 insertions(+), 8 deletions(-)
drivers/net/wireless/ath/ath12k/pci.c +40 -8
@@ -364,16 +364,30 @@ static void ath12k_pci_free_irq(struct ath12k_base *ab)static void ath12k_pci_ce_irq_enable (struct ath12k_base *ab,u16 ce_id) { +struct ath12k_pci *ab_pci =ath12k_pci_priv (ab);u32 irq_idx; +/* In case of one MSI vector, we handle irq enable/disable in a +* uniform way since we only have one irq +*/ +if (!test_bit (ATH12K_PCI_FLAG_MULTI_MSI_VECTORS , &ab_pci->flags)) +return ; + irq_idx =ATH12K_PCI_IRQ_CE0_OFFSET + ce_id;enable_irq (ab->irq_num[irq_idx]); }static void ath12k_pci_ce_irq_disable (struct ath12k_base *ab,u16 ce_id) { +struct ath12k_pci *ab_pci =ath12k_pci_priv (ab);u32 irq_idx; +/* In case of one MSI vector, we handle irq enable/disable in a +* uniform way since we only have one irq +*/ +if (!test_bit (ATH12K_PCI_FLAG_MULTI_MSI_VECTORS , &ab_pci->flags)) +return ; + irq_idx =ATH12K_PCI_IRQ_CE0_OFFSET + ce_id;disable_irq_nosync (ab->irq_num[irq_idx]); }
@@ -433,8 +447,15 @@ static irqreturn_t ath12k_pci_ce_interrupt_handler(int irq, void *arg)static void ath12k_pci_ext_grp_disable (struct ath12k_ext_irq_grp *irq_grp) { +struct ath12k_pci *ab_pci =ath12k_pci_priv (irq_grp->ab);int i; +/* In case of one MSI vector, we handle irq enable/disable +* in a uniform way since we only have one irq +*/ +if (!test_bit (ATH12K_PCI_FLAG_MULTI_MSI_VECTORS , &ab_pci->flags)) +return ; +for (i =0 ; i < irq_grp->num_irq; i++)disable_irq_nosync (irq_grp->ab->irq_num[irq_grp->irqs[i]]); }
@@ -461,8 +482,15 @@ static void __ath12k_pci_ext_irq_disable(struct ath12k_base *ab)static void ath12k_pci_ext_grp_enable (struct ath12k_ext_irq_grp *irq_grp) { +struct ath12k_pci *ab_pci =ath12k_pci_priv (irq_grp->ab);int i; +/* In case of one MSI vector, we handle irq enable/disable in a +* uniform way since we only have one irq +*/ +if (!test_bit (ATH12K_PCI_FLAG_MULTI_MSI_VECTORS , &ab_pci->flags)) +return ; +for (i =0 ; i < irq_grp->num_irq; i++)enable_irq (irq_grp->ab->irq_num[irq_grp->irqs[i]]); }
@@ -523,6 +551,7 @@ static irqreturn_t ath12k_pci_ext_interrupt_handler(int irq, void *arg)static int ath12k_pci_ext_irq_config (struct ath12k_base *ab) { +struct ath12k_pci *ab_pci =ath12k_pci_priv (ab);int i, j, ret, num_vectors =0 ;u32 user_base_data =0 , base_vector =0 , base_idx;
@@ -569,16 +598,15 @@ static int ath12k_pci_ext_irq_config(struct ath12k_base *ab)irq_set_status_flags (irq,IRQ_DISABLE_UNLAZY ); ret =request_irq (irq, ath12k_pci_ext_interrupt_handler, -IRQF_SHARED , + ab_pci->irq_flags,"DP_EXT_IRQ" , irq_grp);if (ret) {ath12k_err (ab,"failed request irq %d: %d\n" , vector, ret);return ret; } - -disable_irq_nosync (ab->irq_num[irq_idx]); } +ath12k_pci_ext_grp_disable (irq_grp); }return 0 ;
@@ -586,6 +614,7 @@ static int ath12k_pci_ext_irq_config(struct ath12k_base *ab)static int ath12k_pci_config_irq (struct ath12k_base *ab) { +struct ath12k_pci *ab_pci =ath12k_pci_priv (ab);struct ath12k_ce_pipe *ce_pipe;u32 msi_data_start;u32 msi_data_count, msi_data_idx;
@@ -614,7 +643,7 @@ static int ath12k_pci_config_irq(struct ath12k_base *ab)tasklet_setup (&ce_pipe->intr_tq, ath12k_pci_ce_tasklet); ret =request_irq (irq, ath12k_pci_ce_interrupt_handler, -IRQF_SHARED , irq_name[irq_idx], + ab_pci->irq_flags, irq_name[irq_idx], ce_pipe);if (ret) { ath12k_err(ab, "failed to request irq %d: %d\n",
@@ -709,6 +738,9 @@ static int ath12k_pci_msi_alloc(struct ath12k_pci *ab_pci)return -EINVAL ; else return num_vectors; + }else { +set_bit (ATH12K_PCI_FLAG_MULTI_MSI_VECTORS , &ab_pci->flags); + ab_pci->irq_flags =IRQF_SHARED ; }ath12k_pci_msi_disable (ab_pci);
@@ -922,11 +954,11 @@ int ath12k_pci_get_user_msi_assignment(struct ath12k_base *ab, char *user_name,for (idx =0 ; idx < msi_config->total_users; idx++) {if (strcmp (user_name, msi_config->users[idx].name) ==0 ) { *num_vectors = msi_config->users[idx].num_vectors; - *user_base_data = msi_config->users[idx].base_vector - + ab_pci->msi_ep_base_data; - *base_vector = msi_config->users[idx].base_vector; + *base_vector = msi_config->users[idx].base_vector; + *user_base_data = *base_vector + ab_pci->msi_ep_base_data; -ath12k_dbg (ab,ATH12K_DBG_PCI ,"Assign MSI to user: %s, num_vectors: %d, user_base_data: %u, base_vector: %u\n" , +ath12k_dbg (ab,ATH12K_DBG_PCI , +"Assign MSI to user: %s, num_vectors: %d, user_base_data: %u, base_vector: %u\n" , user_name, *num_vectors, *user_base_data, *base_vector);
drivers/net/wireless/ath/ath12k/pci.h +2 -0
@@ -86,6 +86,7 @@ enum ath12k_pci_flags {ATH12K_PCI_FLAG_INIT_DONE ,ATH12K_PCI_FLAG_IS_MSI_64 ,ATH12K_PCI_ASPM_RESTORE , + ATH12K_PCI_FLAG_MULTI_MSI_VECTORS, }; struct ath12k_pci_ops {
@@ -110,6 +111,7 @@ struct ath12k_pci {/* enum ath12k_pci_flags */ unsigned long flags;u16 link_ctl; +unsigned long irq_flags;const struct ath12k_pci_ops *pci_ops; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2109/3318 wifi: ath12k: allocate dummy net_device dynamically
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
[ Upstream commit 4f9206e8c2c15a3770e3eb0b9755a05d559fecea ]
Embedding net_device into structures prohibits the usage of flexible arrays in the net_device structure. For more details, see the discussion at [1].
Un-embed the net_device from struct ath12k_ext_irq_grp by converting it into a pointer. Then use the leverage alloc_netdev_dummy() to allocate the net_device object at ath12k_pci_ext_irq_config().
The free of the device occurs at ath12k_pci_free_ext_irq().
Stable-dep-of: 9a78703ec4a8 ("wifi: ath12k: Free allocated external IRQs on request_irq() failure")
--- drivers/net/wireless/ath/ath12k/core.h | 2 +- drivers/net/wireless/ath/ath12k/pci.c | 27 +++++++++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-)
drivers/net/wireless/ath/ath12k/core.h +1 -1
@@ -127,7 +127,7 @@ struct ath12k_ext_irq_grp {u64 timestamp;bool napi_enabled;struct napi_struct napi; -struct net_device napi_ndev; +struct net_device *napi_ndev; };#define HEHANDLE_CAP_PHYINFO_SIZE 3
drivers/net/wireless/ath/ath12k/pci.c +22 -5
@@ -353,6 +353,7 @@ static void ath12k_pci_free_ext_irq(struct ath12k_base *ab)free_irq (ab->irq_num[irq_grp->irqs[j]], irq_grp);netif_napi_del (&irq_grp->napi); +free_netdev (irq_grp->napi_ndev); } }
@@ -552,8 +553,9 @@ static irqreturn_t ath12k_pci_ext_interrupt_handler(int irq, void *arg)static int ath12k_pci_ext_irq_config (struct ath12k_base *ab) {struct ath12k_pci *ab_pci =ath12k_pci_priv (ab); -int i, j, ret, num_vectors =0 ; +int i, j, n, ret, num_vectors =0 ;u32 user_base_data =0 , base_vector =0 , base_idx; +struct ath12k_ext_irq_grp *irq_grp; base_idx =ATH12K_PCI_IRQ_CE0_OFFSET +CE_COUNT_MAX ; ret = ath12k_pci_get_user_msi_assignment(ab, "DP",
@@ -564,13 +566,18 @@ static int ath12k_pci_ext_irq_config(struct ath12k_base *ab)return ret;for (i =0 ; i <ATH12K_EXT_IRQ_GRP_NUM_MAX ; i++) { -struct ath12k_ext_irq_grp *irq_grp = &ab->ext_irq_grp[i]; + irq_grp = &ab->ext_irq_grp[i];u32 num_irq =0 ; irq_grp->ab = ab; irq_grp->grp_id = i; -init_dummy_netdev (&irq_grp->napi_ndev); -netif_napi_add (&irq_grp->napi_ndev, &irq_grp->napi, + irq_grp->napi_ndev =alloc_netdev_dummy (0 ); +if (!irq_grp->napi_ndev) { + ret = -ENOMEM ; + goto fail_allocate; + } + +netif_napi_add (irq_grp->napi_ndev, &irq_grp->napi, ath12k_pci_ext_grp_napi_poll); if (ab->hw_params->ring_mask->tx[i] ||
@@ -603,13 +610,23 @@ static int ath12k_pci_ext_irq_config(struct ath12k_base *ab)if (ret) {ath12k_err (ab,"failed request irq %d: %d\n" , vector, ret); -return ret; + goto fail_request; } }ath12k_pci_ext_grp_disable (irq_grp); }return 0 ; + +fail_request: +/* i ->napi_ndev was properly allocated. Free it also */ + i +=1 ; +fail_allocate: +for (n =0 ; n < i; n++) { + irq_grp = &ab->ext_irq_grp[n]; +free_netdev (irq_grp->napi_ndev); + } +return ret; }static int ath12k_pci_config_irq (struct ath12k_base *ab)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2110/3318 wifi: ath12k: Free allocated external IRQs on request_irq() failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaradhana Sahu <[email protected]>
[ Upstream commit 9a78703ec4a895bd2e99bf43bd18d76683126c19 ]
When external IRQ configuration fails, the driver does not release all IRQs that were successfully requested before the failure. This can leak IRQ resources during probe failure.
Free previously requested external IRQs when external IRQ configuration fails.
Also remove the NAPI instance with netif_napi_del() before freeing the associated netdev to properly clean up the NAPI resources.
Store the IRQ number only after request_irq() succeeds to avoid recording an IRQ that was not successfully requested.
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.6-01243-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath12k/pci.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/net/wireless/ath/ath12k/pci.c +13 -13
@@ -342,11 +342,11 @@ static void ath12k_pci_free_ce_irq(struct ath12k_base *ab, int num_ce) } } -static void ath12k_pci_free_ext_irq (struct ath12k_base *ab) +static void ath12k_pci_free_ext_irq (struct ath12k_base *ab,int num_ext_irq_grp) {int i, j; -for (i =0 ; i <ATH12K_EXT_IRQ_GRP_NUM_MAX ; i++) { +for (i =0 ; i < num_ext_irq_grp; i++) {struct ath12k_ext_irq_grp *irq_grp = &ab->ext_irq_grp[i];for (j =0 ; j < irq_grp->num_irq; j++)
@@ -360,7 +360,7 @@ static void ath12k_pci_free_ext_irq(struct ath12k_base *ab)static void ath12k_pci_free_irq (struct ath12k_base *ab) {ath12k_pci_free_ce_irq (ab, ab->hw_params->ce_count); -ath12k_pci_free_ext_irq (ab); +ath12k_pci_free_ext_irq (ab,ATH12K_EXT_IRQ_GRP_NUM_MAX ); }static void ath12k_pci_ce_irq_enable (struct ath12k_base *ab,u16 ce_id)
@@ -598,8 +598,6 @@ static int ath12k_pci_ext_irq_config(struct ath12k_base *ab)int vector = (i % num_vectors) + base_vector;int irq =ath12k_pci_get_msi_irq (ab->dev, vector); - ab->irq_num[irq_idx] = irq; -ath12k_dbg (ab,ATH12K_DBG_PCI ,"irq:%d group:%d\n" , irq, i);
@@ -610,22 +608,24 @@ static int ath12k_pci_ext_irq_config(struct ath12k_base *ab)if (ret) {ath12k_err (ab,"failed request irq %d: %d\n" , vector, ret); - goto fail_request; + +for (n =0 ; n < j; n++) +free_irq (ab->irq_num[irq_grp->irqs[n]], irq_grp); + +netif_napi_del (&ab->ext_irq_grp[i].napi); +free_netdev (ab->ext_irq_grp[i].napi_ndev); + goto fail_allocate; } + + ab->irq_num[irq_idx] = irq; }ath12k_pci_ext_grp_disable (irq_grp); }return 0 ; -fail_request: -/* i ->napi_ndev was properly allocated. Free it also */ - i +=1 ; fail_allocate: -for (n =0 ; n < i; n++) { - irq_grp = &ab->ext_irq_grp[n]; -free_netdev (irq_grp->napi_ndev); - } +ath12k_pci_free_ext_irq (ab, i);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2111/3318 selftests: net: csum: Clean up recv_verify_packet_ipv6
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Anderson <[email protected]>
[ Upstream commit d772cc25ccf772f4cbb81270970cbe1356c23d3e ]
Rename ip_len to payload_len since the length in this case refers only to the payload, and not the entire IP packet like for IPv4. While we're at it, just use the variable directly when calling recv_verify_packet_udp/tcp.
Stable-dep-of: 8342c68435dd ("selftests: net: csum: filter packets by source address and port")
--- tools/testing/selftests/net/csum.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
tools/testing/selftests/net/csum.c +5 -7
@@ -675,22 +675,20 @@ static int recv_verify_packet_ipv6(void *nh, int len) {struct ipv6hdr *ip6h = nh;uint16_t proto = cfg_encap ?IPPROTO_UDP : cfg_proto; -uint16_t ip_len; +uint16_t payload_len;if (len <sizeof (*ip6h) || ip6h->nexthdr != proto)return -1 ; - ip_len =ntohs (ip6h->payload_len); -if (ip_len > len -sizeof (*ip6h)) + payload_len =ntohs (ip6h->payload_len); +if (payload_len > len -sizeof (*ip6h))return -1 ; - len = ip_len; iph_addr_p = &ip6h->saddr; -if (proto ==IPPROTO_TCP ) -return recv_verify_packet_tcp (ip6h +1 , len); +return recv_verify_packet_tcp (ip6h +1 , payload_len);else -return recv_verify_packet_udp (ip6h +1 , len); +return recv_verify_packet_udp (ip6h +1 , payload_len); }/* return whether auxdata includes TP_STATUS_CSUM_VALID */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2112/3318 selftests: net: csum: filter packets by source address and port
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Willem de Bruijn <[email protected]>
[ Upstream commit 8342c68435dd34b1ecd65b02fff9745cadab2616 ]
Add source address and port verification in recv_verify_packet_* andrecv_udp: non-matching packets are skipped.
The receiver reads from PF_PACKET and UDP sockets to verify incoming packets to test hardware checksum offload. It did not validate the packet source address or source port.
During tests expecting an invalid checksum (-E) or zero checksum (-Z), background packets can fail the test.
For -Z, build_packet_udp chooses a specific source port that causes the checksum to sum to zero. When running in receive-only mode (-R), call build_packet in do_rx to compute the expected source port so that source port filtering can be applied to -Z as well.
Also
- add an inter-packet delay to avoid drops from bursts.
- remove a comment that is no longer correct.
--- tools/testing/selftests/net/csum.c | 55 +++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 5 deletions(-)
tools/testing/selftests/net/csum.c +50 -5
@@ -2,8 +2,7 @@/* Test hardware checksum offload: Rx + Tx, IPv4 + IPv6, TCP + UDP. * -* The test runs on two machines to exercise the NIC. For this reason it -* is not integrated in kselftests. +* The test runs on two machines to exercise the NIC. * * CMD=$((./csum -[46] -[tu] -S $SADDR -D $DADDR -[RT] -r 1 $EXTRA_ARGS)) *
@@ -236,7 +235,8 @@ static void *build_packet_udp(void *_uh) uh->source =0 ; uh->source =checksum (uh,IPPROTO_UDP ,sizeof (*uh) + cfg_payload_len); -fprintf (stderr,"tx: changing sport: %hu -> %hu\n" , +fprintf (stderr,"%s: changing sport: %hu -> %hu\n" , + cfg_do_tx ?"tx" :"rx" , cfg_port_src,ntohs (uh->source)); cfg_port_src =ntohs (uh->source); }
@@ -249,7 +249,8 @@ static void *build_packet_udp(void *_uh)if (cfg_bad_csum) uh->check = ~uh->check; -fprintf (stderr,"tx: sending checksum: 0x%x\n" , uh->check); +if (cfg_do_tx) +fprintf (stderr,"tx: sending checksum: 0x%x\n" , uh->check);return uh +1 ; }
@@ -571,15 +572,36 @@ static int recv_prepare_packet(void)static int recv_udp (int fd) {static char buf[MAX_PAYLOAD_LEN ]; +struct sockaddr_storage addr; +socklen_t addrlen;int ret, count =0 ;while (1 ) { - ret =recv (fd, buf,sizeof (buf),MSG_DONTWAIT ); + addrlen =sizeof (addr); + ret =recvfrom (fd, buf,sizeof (buf),MSG_DONTWAIT , + (struct sockaddr *)&addr, &addrlen);if (ret ==-1 && errno ==EAGAIN )break ;if (ret ==-1 )error (1 , errno,"recv r" ); +if (cfg_family ==PF_INET ) { +struct sockaddr_in *sin = (void *)&addr; + +if (sin->sin_addr.s_addr != cfg_saddr4.sin_addr.s_addr) +continue ; +if (sin->sin_port !=htons (cfg_port_src)) +continue ; + }else { +struct sockaddr_in6 *sin6 = (void *)&addr; + +if (memcmp (&sin6->sin6_addr, &cfg_saddr6.sin6_addr, +sizeof (sin6->sin6_addr))) +continue ; +if (sin6->sin6_port !=htons (cfg_port_src)) +continue ; + } +fprintf (stderr,"rx: udp: len=%u\n" , ret); count++; }
@@ -620,6 +642,9 @@ static int recv_verify_packet_tcp(void *th, int len)if (len <sizeof (*tcph) || tcph->dest !=htons (cfg_port_dst))return -1 ; +if (tcph->source !=htons (cfg_port_src)) +return -1 ; +return recv_verify_csum (th, len,ntohs (tcph->source), tcph->check); }
@@ -647,6 +672,9 @@ static int recv_verify_packet_udp(void *th, int len)return recv_verify_packet_udp_encap (udph +1 , len -sizeof (*udph)); +if (udph->source !=htons (cfg_port_src)) +return -1 ; +return recv_verify_csum (th, len,ntohs (udph->source), udph->check); }
@@ -659,6 +687,9 @@ static int recv_verify_packet_ipv4(void *nh, int len)if (len <sizeof (*iph) || iph->protocol != proto)return -1 ; +if (iph->saddr != cfg_saddr4.sin_addr.s_addr) +return -1 ; + ip_len =ntohs (iph->tot_len);if (ip_len > len || ip_len <sizeof (*iph))return -1 ;
@@ -680,6 +711,9 @@ static int recv_verify_packet_ipv6(void *nh, int len)if (len <sizeof (*ip6h) || ip6h->nexthdr != proto)return -1 ; +if (memcmp (&ip6h->saddr, &cfg_saddr6.sin6_addr,sizeof (ip6h->saddr))) +return -1 ; + payload_len =ntohs (ip6h->payload_len);if (payload_len > len -sizeof (*ip6h))return -1 ;
@@ -928,6 +962,9 @@ static void do_tx(void) cfg_payload_len =rand () %MAX_PAYLOAD_LEN ; buf =build_packet (_buf,sizeof (_buf), &len); } + +/* avoid bursting */ +usleep (20 ); }if (close (fd))
@@ -940,6 +977,14 @@ static void do_rx(int fdp, int fdr)long tleft, tstop;struct pollfd pfd; +if (!cfg_do_tx && cfg_zero_sum) { +static char _buf[MAX_HEADER_LEN +MAX_PAYLOAD_LEN ]; +int len; + +/* calculate source port that causes csum to add up to zero */ +build_packet (_buf,sizeof (_buf), &len); + } + tstop =gettimeofday_ms () + cfg_timeout_ms; tleft = cfg_timeout_ms;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2113/3318 power: supply: mp2629: Use the full batt_impedance_compensation name in the ABI document
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 1101833121a447999309a01f03d5b35bc1652e09 ]
drivers/power/supply/mp2629_charger.c creates the attribute with DEVICE_ATTR_RW(batt_impedance_compensation). The ABI file documents it under the truncated name batt_impedance_compen, which does not exist in sysfs.
Use the full name.
--- Documentation/ABI/testing/sysfs-class-power-mp2629 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-class-power-mp2629 +1 -1
@@ -1,4 +1,4 @@ -What: /sys/class/power_supply/mp2629_battery/batt_impedance_compen +What: /sys/class/power_supply/mp2629_battery/batt_impedance_compensation Date: April 2020 KernelVersion: 5.7 Description:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2114/3318 PM: wakeup: implement devm_device_init_wakeup() helper
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joe Hattori <[email protected]>
[ Upstream commit b317268368546d6401af788648668f82e3ba1bd3 ]
Some drivers that enable device wakeup fail to properly disable it during their cleanup, which results in a memory leak.
To address this, introduce devm_device_init_wakeup(), a managed variant of device_init_wakeup(dev, true).
With this managed helper, wakeup functionality will be automatically disabled when the device is released, ensuring a more reliable cleanup process.
This need for this addition arose during a previous discussion [1].
Stable-dep-of: ece9baab2a6e ("power: supply: bq24190_charger: use the wake irq API")
--- include/linux/pm_wakeup.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
include/linux/pm_wakeup.h +17 -0
@@ -242,4 +242,21 @@ static inline int device_init_wakeup(struct device *dev, bool enable) } } +static void device_disable_wakeup (void *dev) +{ +device_init_wakeup (dev, false); +} + +/** +* devm_device_init_wakeup - Resource managed device wakeup initialization. +* @dev: Device to handle. +* +* This function is the devm managed version of device_init_wakeup(dev, true). +*/ +static inline int devm_device_init_wakeup (struct device *dev) +{ +device_init_wakeup (dev, true); +return devm_add_action_or_reset (dev, device_disable_wakeup, dev); +} +#endif /* _LINUX_PM_WAKEUP_H */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2115/3318 PM: sleep: wakeirq: Introduce device-managed variant of dev_pm_set_wake_irq()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peng Fan <[email protected]>
[ Upstream commit fd8318a32573d73eb20637a0c80689de0dc98169 ]
Add device-managed variant of dev_pm_set_wake_irq which automatically clear the wake irq on device destruction to simplify error handling and resource management in drivers.
Stable-dep-of: ece9baab2a6e ("power: supply: bq24190_charger: use the wake irq API")
--- drivers/base/power/wakeirq.c | 26 ++++++++++++++++++++++++++ include/linux/pm_wakeirq.h | 6 ++++++ 2 files changed, 32 insertions(+)
drivers/base/power/wakeirq.c +26 -0
@@ -106,6 +106,32 @@ void dev_pm_clear_wake_irq(struct device *dev) }EXPORT_SYMBOL_GPL (dev_pm_clear_wake_irq); +static void devm_pm_clear_wake_irq (void *dev) +{ +dev_pm_clear_wake_irq (dev); +} + +/** +* devm_pm_set_wake_irq - device-managed variant of dev_pm_set_wake_irq +* @dev: Device entry +* @irq: Device IO interrupt +* +* +* Attach a device IO interrupt as a wake IRQ, same with dev_pm_set_wake_irq, +* but the device will be auto clear wake capability on driver detach. +*/ +int devm_pm_set_wake_irq (struct device *dev,int irq) +{ +int ret; + + ret =dev_pm_set_wake_irq (dev, irq); +if (ret) +return ret; + +return devm_add_action_or_reset (dev, devm_pm_clear_wake_irq, dev); +} +EXPORT_SYMBOL_GPL (devm_pm_set_wake_irq); +/** * handle_threaded_wake_irq - Handler for dedicated wake-up interrupts * @irq: Device specific dedicated wake-up interrupt
include/linux/pm_wakeirq.h +6 -0
@@ -10,6 +10,7 @@ extern int dev_pm_set_wake_irq(struct device *dev, int irq);extern int dev_pm_set_dedicated_wake_irq (struct device *dev,int irq);extern int dev_pm_set_dedicated_wake_irq_reverse (struct device *dev,int irq);extern void dev_pm_clear_wake_irq (struct device *dev); +extern int devm_pm_set_wake_irq (struct device *dev,int irq);#else /* !CONFIG_PM */
@@ -32,5 +33,10 @@ static inline void dev_pm_clear_wake_irq(struct device *dev) { } +static inline int devm_pm_set_wake_irq (struct device *dev,int irq) +{ +return 0 ; +} +#endif /* CONFIG_PM */ #endif /* _LINUX_PM_WAKEIRQ_H */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2116/3318 power: supply: bq24190_charger: use the wake irq API
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryan Brue <[email protected]>
[ Upstream commit ece9baab2a6e79224d3f591893be23b540b1625f ]
bq24190_probe() calls enable_irq_wake() on the charger interrupt and never calls disable_irq_wake(). That is wrong in three ways.
It is unbalanced. free_irq() does not touch desc->wake_depth -- only irq_set_irq_wake() does -- so after the driver is unbound the descriptor is still one wake reference deep and the irqchip is still configured for wake, forever, for an interrupt nobody owns any more.
It ignores the device's wakeup policy. The chip is made a system wake source whether or not anyone asked for it, and because device_init_wakeup() is never called there is no power/wakeup attribute for userspace to say otherwise. A board that would rather not be woken by its charger has no way to express that.
And it arms the interrupt for wake permanently, from probe onwards, rather than for the sleep it is meant to cover.
Use the wake irq API instead: devm_device_init_wakeup() to make the device wakeup-capable and enabled -- preserving today's behaviour -- and devm_pm_set_wake_irq() to hand the interrupt to the PM core, which arms it in dpm_suspend_noirq() (only if device_may_wakeup(), immediately before suspend_device_irqs()) and disarms it on resume. Both are unwound by devm, so the reference is balanced on unbind, and userspace gets the power/wakeup control it should have had.
No intended change in behaviour: charger events still wake the system by default.
The same conversion was made to another charger driver for the same reason, in commit 6c5393771c50 ("power: supply: qcom_pmi8998_charger: fix wakeirq").
--- drivers/power/supply/bq24190_charger.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/power/supply/bq24190_charger.c +8 -1
@@ -10,6 +10,7 @@#include <linux/interrupt.h> #include <linux/delay.h> #include <linux/pm_runtime.h> +#include <linux/pm_wakeirq.h> #include <linux/power_supply.h> #include <linux/power/bq24190_charger.h> #include <linux/regulator/driver.h>
@@ -1896,7 +1897,13 @@ static int bq24190_probe(struct i2c_client *client)if (ret <0 ) goto out_charger; -enable_irq_wake (client->irq); + ret =devm_device_init_wakeup (dev); +if (ret <0 ) + goto out_charger; + + ret =devm_pm_set_wake_irq (dev, client->irq); +if (ret <0 ) + goto out_charger;pm_runtime_mark_last_busy (dev);pm_runtime_put_autosuspend (dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2117/3318 power: supply: bq2515x: Propagate charge-enable read errors
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linmao Li <[email protected]>
[ Upstream commit 4a35810a847411c466a15d1737d11e8e818dc197 ]
bq2515x_get_charge_disable() returns bool even though reading the charger-disable state can fail. A negative error is therefore converted to true, so POWER_SUPPLY_PROP_STATUS reports NOT_CHARGING with success instead of propagating the failure. The GPIO read is not checked for errors either.
Return an int from the helper, check both reads, and only convert a valid charger-disable state to the charging-status boolean.
--- drivers/power/supply/bq2515x_charger.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/power/supply/bq2515x_charger.c +9 -6
@@ -415,7 +415,7 @@ static int bq2515x_get_battery_current_now(struct bq2515x_device *bq2515x) BQ2515X_ICHG_DIVISOR); } -static bool bq2515x_get_charge_disable (struct bq2515x_device *bq2515x) +static int bq2515x_get_charge_disable (struct bq2515x_device *bq2515x) {int ret;int ce_pin;
@@ -423,6 +423,8 @@ static bool bq2515x_get_charge_disable(struct bq2515x_device *bq2515x)int charger_disable; ce_pin =gpiod_get_value_cansleep (bq2515x->ce_gpio); +if (ce_pin <0 ) +return ce_pin; ret =regmap_read (bq2515x->regmap,BQ2515X_ICCTRL2 , &icctrl2);if (ret)
@@ -430,10 +432,7 @@ static bool bq2515x_get_charge_disable(struct bq2515x_device *bq2515x) charger_disable = icctrl2 &BQ2515X_CHARGER_DISABLE ; -if (charger_disable || ce_pin) -return true; - -return false; +return charger_disable || ce_pin; }static int bq2515x_set_charge_disable (struct bq2515x_device *bq2515x,int val)
@@ -610,7 +609,11 @@ static int bq2515x_charging_status(struct bq2515x_device *bq2515x,else status1_no_fault = false; - ce_status = (!bq2515x_get_charge_disable (bq2515x)); + ret =bq2515x_get_charge_disable (bq2515x); +if (ret <0 ) +return ret; + + ce_status = !ret;/* * If there are no faults and charging is enabled, then status is
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2118/3318 scsi: mpi3mr: Fix buffer overflow in BSG passthrough request copy
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 896abdd4d81f40575b05d593f7fe004935a6cf97 ]
The size of an incoming BSG request is checked using a variable that is narrower than the field it is read from, so large values wrap and pass the check. The copy that follows then uses the full value and writes past the request buffer.
Widen the variable and copy only the amount that was checked.
--- drivers/scsi/mpi3mr/mpi3mr_app.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_app.c +2 -2
@@ -960,7 +960,7 @@ static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job, unsigned int *replystruct mpi3mr_ioc *mrioc =NULL ;u8 *mpi_req =NULL , *sense_buff_k =NULL ; -u8 mpi_msg_size =0 ; +u32 mpi_msg_size =0 ;struct mpi3mr_bsg_packet *bsg_req =NULL ;struct mpi3mr_bsg_mptcmd *karg;struct mpi3mr_buf_entry *buf_entries =NULL ;
@@ -1099,7 +1099,7 @@ static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job, unsigned int *reply rval = -EINVAL ; goto out; } -memcpy (mpi_req, sgl_iter, buf_entries->buf_len); +memcpy (mpi_req, sgl_iter, mpi_msg_size);break ;default : invalid_be =1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2119/3318 scsi: mpi3mr: Fix out-of-bounds read when copying BSG MPI requests
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 9fac4cbd66d852958e8a8d0952eb57f8554ce83b ]
The MPI request is copied out of the caller supplied payload without first checking that the requested amount is actually present, so the copy can read past the end of the payload buffer.
Check the range before copying.
--- drivers/scsi/mpi3mr/mpi3mr_app.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/scsi/mpi3mr/mpi3mr_app.c +8 -0
@@ -1099,6 +1099,14 @@ static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job, unsigned int *reply rval = -EINVAL ; goto out; } +if (sgl_iter + mpi_msg_size > + dout_buf + job->request_payload.payload_len) { +dprint_bsg_err (mrioc,"%s: MPI request buf exceeds dout_buf\n" , + __func__); +mutex_unlock (&mrioc->bsg_cmds.mutex); + rval = -EINVAL ; + goto out; + }memcpy (mpi_req, sgl_iter, mpi_msg_size);break ;default :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2120/3318 scsi: mpi3mr: Fix I/O block counter leak on admin request post failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 37e7d274272bc5e545e2d5f9261afa7f33f1cf49 ]
The per device I/O block counter is raised before a task management request is posted and only lowered once the request completes. If the post itself fails the counter stays raised and I/O to that device remains blocked.
Lower it on the failure path as well.
--- drivers/scsi/mpi3mr/mpi3mr_app.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/mpi3mr/mpi3mr_app.c +2 -0
@@ -1295,6 +1295,8 @@ static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job, unsigned int *replydprint_bsg_err (mrioc,"%s: posting bsg request is failed\n" , __func__); rval = -EAGAIN ; +if (block_io && stgt_priv) +atomic_dec (&stgt_priv->block_io); goto out_unlock; } wait_for_completion_timeout(&mrioc->bsg_cmds.done,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2121/3318 scsi: mpi3mr: Fix target device reference leak in BSG task management
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit f0ec04bdf6156ed2ae7d86a8819dafdd9383b705 ]
The target device lookup takes a reference, but it is only dropped inside a branch that also requires the SCSI target data to be set up. When it is not, the reference is leaked.
Drop the reference whenever the lookup succeeded.
--- drivers/scsi/mpi3mr/mpi3mr_app.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_app.c +6 -4
@@ -1258,10 +1258,12 @@ static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job, unsigned int *reply }if (block_io) { tgtdev =mpi3mr_get_tgtdev_by_handle (mrioc, dev_handle); -if (tgtdev && tgtdev->starget && tgtdev->starget->hostdata) { - stgt_priv = (struct mpi3mr_stgt_priv_data *) - tgtdev->starget->hostdata; -atomic_inc (&stgt_priv->block_io); +if (tgtdev) { +if (tgtdev->starget && tgtdev->starget->hostdata) { + stgt_priv = (struct mpi3mr_stgt_priv_data *) + tgtdev->starget->hostdata; +atomic_inc (&stgt_priv->block_io); + }mpi3mr_tgtdev_put (tgtdev); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2122/3318 scsi: mpi3mr: Fix buffer overflow when caching log data
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 9ff1af19c488efad66f2b803eefa0abd5fdac8f4 ]
Each log data slot holds a header followed by the payload, but the copy was sized against the whole slot and so wrote one header length past the end of it. Subtracting the header on its own is not enough either, because the entry size is derived from the controller reply size and can be smaller than the header.
Work out the payload room first and clamp the copy to it.
--- drivers/scsi/mpi3mr/mpi3mr_app.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_app.c +8 -2
@@ -1449,7 +1449,8 @@ static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job, unsigned int *replyvoid mpi3mr_app_save_logdata (struct mpi3mr_ioc *mrioc,char *event_data,u16 event_data_size) { -u32 index = mrioc->logdata_buf_idx, sz; +u32 index = mrioc->logdata_buf_idx; +size_t entry_payload_len, sz;struct mpi3mr_logdata_entry *entry;if (!(mrioc->logdata_buf))
@@ -1458,7 +1459,12 @@ void mpi3mr_app_save_logdata(struct mpi3mr_ioc *mrioc, char *event_data, entry = (struct mpi3mr_logdata_entry *) (mrioc->logdata_buf + (index * mrioc->logdata_entry_sz)); entry->valid_entry =1 ; - sz =min (mrioc->logdata_entry_sz, event_data_size); +if (mrioc->logdata_entry_sz >MPI3MR_BSG_LOGDATA_ENTRY_HEADER_SZ ) + entry_payload_len = (size_t )mrioc->logdata_entry_sz - +MPI3MR_BSG_LOGDATA_ENTRY_HEADER_SZ ; +else + entry_payload_len =0 ; + sz =min_t (size_t, entry_payload_len, event_data_size);memcpy (entry->data, event_data, sz); mrioc->logdata_buf_idx = ((++index) %MPI3MR_BSG_LOGDATA_MAX_ENTRIES );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2123/3318 scsi: mpi3mr: Fix out-of-bounds reply frame access
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit bcf0a5bed59acd5ae19d80e1f617c1a5b355af0b ]
The reply frame address reported on completion is only checked against the start and the end of the pool. An address near the top can pass the check while leaving less than a full frame, and an unaligned one resolves into the middle of a frame instead of the start of one.
Require a whole frame to fit and the address to be frame aligned.
--- drivers/scsi/mpi3mr/mpi3mr_fw.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/scsi/mpi3mr/mpi3mr_fw.c +6 -1
@@ -119,11 +119,16 @@ void mpi3mr_build_zero_len_sge(void *paddr)void *mpi3mr_get_reply_virt_addr (struct mpi3mr_ioc *mrioc,dma_addr_t phys_addr) { +u64 offset; +if (!phys_addr)return NULL ; + offset = phys_addr - mrioc->reply_buf_dma; +if ((phys_addr < mrioc->reply_buf_dma) || - (phys_addr > mrioc->reply_buf_dma_max_address)) + (phys_addr > mrioc->reply_buf_dma_max_address - mrioc->reply_sz) || +do_div (offset, mrioc->reply_sz))return NULL ;return mrioc->reply_buf + (phys_addr - mrioc->reply_buf_dma);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2124/3318 scsi: mpi3mr: Fix out-of-bounds sense buffer access
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 7fea128f6b829ad834f21834d2605d28a45b903d ]
The sense buffer address reported on completion is turned into a virtual address with no range check, so an address outside the pool resolves to memory that does not belong to it.
Check that it lies within the pool and is correctly aligned.
--- drivers/scsi/mpi3mr/mpi3mr_fw.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/scsi/mpi3mr/mpi3mr_fw.c +10 -0
@@ -137,9 +137,19 @@ void *mpi3mr_get_reply_virt_addr(struct mpi3mr_ioc *mrioc,void *mpi3mr_get_sensebuf_virt_addr (struct mpi3mr_ioc *mrioc,dma_addr_t phys_addr) { +u64 offset; +if (!phys_addr)return NULL ; + offset = phys_addr - mrioc->sense_buf_dma; + +if (phys_addr < mrioc->sense_buf_dma || + (phys_addr > mrioc->sense_buf_dma + + (mrioc->num_sense_bufs *MPI3MR_SENSE_BUF_SZ ) -MPI3MR_SENSE_BUF_SZ ) || +do_div (offset,MPI3MR_SENSE_BUF_SZ )) +return NULL ; +return mrioc->sense_buf + (phys_addr - mrioc->sense_buf_dma); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2125/3318 scsi: mpi3mr: Fix out-of-bounds bitmap access during device removal
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 5dade59551d344d0308256edfef6bc3fb4202eb3 ]
Device handles reported by the controller are used to index the remove pending bitmap and to build a task management request without being compared against the maximum handle the controller reported.
Check the handle before using it.
--- drivers/scsi/mpi3mr/mpi3mr_os.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/scsi/mpi3mr/mpi3mr_os.c +16 -1
@@ -2172,7 +2172,8 @@ static void mpi3mr_dev_rmhs_complete_iou(struct mpi3mr_ioc *mrioc,ioc_info (mrioc,"%s :dev removal handshake completed successfully: handle(0x%04x)\n" , __func__, drv_cmd->dev_handle); -clear_bit (drv_cmd->dev_handle, mrioc->removepend_bitmap); +if (drv_cmd->dev_handle < mrioc->facts.max_devhandle) +clear_bit (drv_cmd->dev_handle, mrioc->removepend_bitmap); }if (!list_empty (&mrioc->delayed_rmhs_list)) {
@@ -2286,6 +2287,20 @@ static void mpi3mr_dev_rmhs_send_tm(struct mpi3mr_ioc *mrioc, u16 handle,struct mpi3mr_tgt_dev *tgtdev =NULL ;unsigned long flags; +if (handle >= mrioc->facts.max_devhandle) { +ioc_err (mrioc,"dev_remove_hs: handle(0x%04x) >= max_devhandle(0x%04x)\n" , + handle, mrioc->facts.max_devhandle); +if (drv_cmd) { + cmd_idx = drv_cmd->host_tag -MPI3MR_HOSTTAG_DEVRMCMD_MIN ; + drv_cmd->state =MPI3MR_CMD_NOTUSED ; + drv_cmd->callback =NULL ; + drv_cmd->dev_handle =MPI3MR_INVALID_DEV_HANDLE ; + drv_cmd->retry_count =0 ; +clear_bit (cmd_idx, mrioc->devrem_bitmap); + } +return ; + } +spin_lock_irqsave (&mrioc->tgtdev_lock, flags); tgtdev =__mpi3mr_get_tgtdev_by_handle (mrioc, handle);if (tgtdev && (iou_rc ==MPI3_CTRL_OP_REMOVE_DEVICE ))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2126/3318 scsi: mpi3mr: Fix target device reference leak in device removal handshake
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit a04b0f3a17e32aa449fd896163a7b40efc29c4f5 ]
The device removal handshake looks up the target device to update its state but never drops the reference that the lookup takes.
Drop it once the state has been updated.
--- drivers/scsi/mpi3mr/mpi3mr_os.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/scsi/mpi3mr/mpi3mr_os.c +3 -0
@@ -2307,6 +2307,9 @@ static void mpi3mr_dev_rmhs_send_tm(struct mpi3mr_ioc *mrioc, u16 handle, tgtdev->state =MPI3MR_DEV_REMOVE_HS_STARTED ;spin_unlock_irqrestore (&mrioc->tgtdev_lock, flags); +if (tgtdev) +mpi3mr_tgtdev_put (tgtdev); +if (drv_cmd) goto issue_cmd; do {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2127/3318 scsi: mpi3mr: Fix out-of-bounds read in SAS topology change events
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 9e220ce4bd0468e47cc9eea07e40799ebae6eda8 ]
The number of entries in a SAS topology change event is used to walk the entry array without being compared against the amount of event data that was received, so the walk can run past the end of the buffer.
Work out how many entries the payload can hold and skip the event if it claims more.
--- drivers/scsi/mpi3mr/mpi3mr_os.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_os.c +19 -3
@@ -2600,12 +2600,28 @@ static void mpi3mr_sastopochg_evt_th(struct mpi3mr_ioc *mrioc,struct mpi3_event_data_sas_topology_change_list *topo_evt = (struct mpi3_event_data_sas_topology_change_list *)event_reply->event_data;int i; -u16 handle; -u8 reason_code; +u16 handle, avail_len; +u8 reason_code, max_entries, num_entries;struct mpi3mr_tgt_dev *tgtdev =NULL ;struct mpi3mr_stgt_priv_data *scsi_tgt_priv_data =NULL ; -for (i =0 ; i < topo_evt->num_entries; i++) { + avail_len = event_reply->event_data_length *4 ; +if (avail_len < offsetof(struct mpi3_event_data_sas_topology_change_list , phy_entry)) { +ioc_err (mrioc,"SAS topology event: event data too small (%u bytes)\n" , + avail_len); +return ; + } + max_entries = (avail_len - + offsetof(struct mpi3_event_data_sas_topology_change_list , phy_entry)) / +sizeof (struct mpi3_event_sas_topo_phy_entry ); + num_entries = topo_evt->num_entries; +if (num_entries > max_entries) { +ioc_err (mrioc,"SAS topology event: num_entries(%d) exceeds max(%d)\n" , + num_entries, max_entries); +return ; + } + +for (i =0 ; i < num_entries; i++) { handle =le16_to_cpu (topo_evt->phy_entry[i].attached_dev_handle);if (!handle)continue ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2128/3318 scsi: mpi3mr: Event processing debug improvement
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ranjan Kumar <[email protected]>
[ Upstream commit 04f79c113ae77732e7e6674bd814e76c7a3453cf ]
Improve event process debugging. Implement more verbose event logging throughout the driver.
Stable-dep-of: 77554f01187d ("scsi: mpi3mr: Fix out-of-bounds read of event data")
--- drivers/scsi/mpi3mr/mpi3mr_os.c | 67 ++++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 17 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_os.c +50 -17
@@ -956,6 +956,10 @@ static int mpi3mr_report_tgtdev_to_host(struct mpi3mr_ioc *mrioc, goto out; } } +dprint_event_bh (mrioc, +"exposed target device with handle(0x%04x), perst_id(%d)\n" , + tgtdev->dev_handle, perst_id); + goto out; }else mpi3mr_report_tgtdev_to_sas_transport (mrioc, tgtdev); out:
@@ -1311,9 +1315,9 @@ static void mpi3mr_devstatuschg_evt_bh(struct mpi3mr_ioc *mrioc, (struct mpi3_event_data_device_status_change *)fwevt->event_data; dev_handle =le16_to_cpu (evtdata->dev_handle); -ioc_info (mrioc, -"%s :device status change: handle(0x%04x): reason code(0x%x)\n" , - __func__, dev_handle, evtdata->reason_code); +dprint_event_bh (mrioc, +"processing device status change event bottom half for handle(0x%04x), rc(0x%02x)\n" , + dev_handle, evtdata->reason_code);switch (evtdata->reason_code) {case MPI3_EVENT_DEV_STAT_RC_HIDDEN : delete =1 ;
@@ -1332,8 +1336,13 @@ static void mpi3mr_devstatuschg_evt_bh(struct mpi3mr_ioc *mrioc, } tgtdev =mpi3mr_get_tgtdev_by_handle (mrioc, dev_handle); -if (!tgtdev) +if (!tgtdev) { +dprint_event_bh (mrioc, +"processing device status change event bottom half,\n" +"cannot identify target device for handle(0x%04x), rc(0x%02x)\n" , + dev_handle, evtdata->reason_code); goto out; + }if (uhide) { tgtdev->is_hidden =0 ;if (!tgtdev->host_exposed)
@@ -1373,12 +1382,17 @@ static void mpi3mr_devinfochg_evt_bh(struct mpi3mr_ioc *mrioc, perst_id =le16_to_cpu (dev_pg0->persistent_id); dev_handle =le16_to_cpu (dev_pg0->dev_handle); -ioc_info (mrioc, -"%s :Device info change: handle(0x%04x): persist_id(0x%x)\n" , - __func__, dev_handle, perst_id); +dprint_event_bh (mrioc, +"processing device info change event bottom half for handle(0x%04x), perst_id(%d)\n" , + dev_handle, perst_id); tgtdev =mpi3mr_get_tgtdev_by_handle (mrioc, dev_handle); -if (!tgtdev) +if (!tgtdev) { +dprint_event_bh (mrioc, +"cannot identify target device for device info\n" +"change event handle(0x%04x), perst_id(%d)\n" , + dev_handle, perst_id); goto out; + }mpi3mr_update_tgtdev (mrioc, tgtdev, dev_pg0, false);if (!tgtdev->is_hidden && !tgtdev->host_exposed)mpi3mr_report_tgtdev_to_host (mrioc, perst_id);
@@ -1922,8 +1936,11 @@ static void mpi3mr_fwevt_bh(struct mpi3mr_ioc *mrioc,mpi3mr_fwevt_del_from_list (mrioc, fwevt); mrioc->current_event = fwevt; -if (mrioc->stop_drv_processing) +if (mrioc->stop_drv_processing) { +dprint_event_bh (mrioc,"ignoring event(0x%02x) in the bottom half handler\n" +"due to stop_drv_processing\n" , fwevt->event_id); goto out; + }if (mrioc->unrecoverable) { dprint_event_bh(mrioc,
@@ -1935,6 +1952,9 @@ static void mpi3mr_fwevt_bh(struct mpi3mr_ioc *mrioc,if (!fwevt->process_evt) goto evt_ack; +dprint_event_bh (mrioc,"processing event(0x%02x) in the bottom half handler\n" , + fwevt->event_id); +switch (fwevt->event_id) {case MPI3_EVENT_DEVICE_ADDED : {
@@ -2691,6 +2711,9 @@ static void mpi3mr_devstatuschg_evt_th(struct mpi3mr_ioc *mrioc, goto out; dev_handle =le16_to_cpu (evtdata->dev_handle); +dprint_event_th (mrioc, +"device status change event top half with rc(0x%02x) for handle(0x%04x)\n" , + evtdata->reason_code, dev_handle);switch (evtdata->reason_code) {case MPI3_EVENT_DEV_STAT_RC_INT_DEVICE_RESET_STRT :
@@ -2714,8 +2737,12 @@ static void mpi3mr_devstatuschg_evt_th(struct mpi3mr_ioc *mrioc, } tgtdev =mpi3mr_get_tgtdev_by_handle (mrioc, dev_handle); -if (!tgtdev) +if (!tgtdev) { +dprint_event_th (mrioc, +"processing device status change event could not identify device for handle(0x%04x)\n" , + dev_handle); goto out; + }if (hide) tgtdev->is_hidden = hide;if (tgtdev->starget && tgtdev->starget->hostdata) {
@@ -2791,13 +2818,13 @@ static void mpi3mr_energypackchg_evt_th(struct mpi3mr_ioc *mrioc,u16 shutdown_timeout =le16_to_cpu (evtdata->shutdown_timeout);if (shutdown_timeout <=0 ) { -ioc_warn (mrioc, +dprint_event_th (mrioc,"%s :Invalid Shutdown Timeout received = %d\n" , __func__, shutdown_timeout);return ; } -ioc_info (mrioc, +dprint_event_th (mrioc,"%s :Previous Shutdown Timeout Value = %d New Shutdown Timeout Value = %d\n" , __func__, mrioc->facts.shutdown_timeout, shutdown_timeout); mrioc->facts.shutdown_timeout = shutdown_timeout;
@@ -2901,9 +2928,11 @@ void mpi3mr_os_handle_events(struct mpi3mr_ioc *mrioc,struct mpi3_device_page0 *dev_pg0 = (struct mpi3_device_page0 *)event_reply->event_data;if (mpi3mr_create_tgtdev (mrioc, dev_pg0)) -ioc_err (mrioc, -"%s :Failed to add device in the device add event\n" , - __func__); +dprint_event_th (mrioc, +"failed to process device added event for handle(0x%04x),\n" +"perst_id(%d) in the event top half handler\n" , +le16_to_cpu (dev_pg0->dev_handle), +le16_to_cpu (dev_pg0->persistent_id));else process_evt_bh =1 ;break ;
@@ -2961,11 +2990,15 @@ void mpi3mr_os_handle_events(struct mpi3mr_ioc *mrioc,break ; }if (process_evt_bh || ack_req) { +dprint_event_th (mrioc, +"scheduling bottom half handler for event(0x%02x),ack_required=%d\n" , + evt_type, ack_req); sz = event_reply->event_data_length *4 ; fwevt =mpi3mr_alloc_fwevt (sz);if (!fwevt) { -ioc_info (mrioc,"%s :failure at %s:%d/%s()!\n" , - __func__, __FILE__, __LINE__, __func__); +dprint_event_th (mrioc, +"failed to schedule bottom half handler for\n" +"event(0x%02x), ack_required=%d\n" , evt_type, ack_req);return ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2129/3318 scsi: mpi3mr: Fix device loss during enclosure reboot due to zero link speed
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit d6c8e8b7c98c3cb326515ef4bc5c57e16ac5ae4e ]
During enclosure reboot or expander reset, firmware may report a link speed of 0 in "Device Add" events while the link is still coming up. The driver drops such devices, leaving them missing even after the link recovers.
Fix this by treating link speed 0 as 1.5 Gbps during device addition so the device is exposed to the OS. The actual link speed will be updated later when link-up events arrive.
Stable-dep-of: 77554f01187d ("scsi: mpi3mr: Fix out-of-bounds read of event data")
--- drivers/scsi/mpi3mr/mpi3mr_os.c | 8 ++++---- drivers/scsi/mpi3mr/mpi3mr_transport.c | 11 +++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_os.c +4 -4
@@ -1952,8 +1952,8 @@ static void mpi3mr_fwevt_bh(struct mpi3mr_ioc *mrioc,if (!fwevt->process_evt) goto evt_ack; -dprint_event_bh (mrioc,"processing event(0x%02x) in the bottom half handler\n" , - fwevt->event_id); +dprint_event_bh (mrioc,"processing event(0x%02x) -(0x%08x) in the bottom half handler\n" , + fwevt->event_id, fwevt->evt_ctx);switch (fwevt->event_id) {case MPI3_EVENT_DEVICE_ADDED :
@@ -2991,8 +2991,8 @@ void mpi3mr_os_handle_events(struct mpi3mr_ioc *mrioc, }if (process_evt_bh || ack_req) {dprint_event_th (mrioc, -"scheduling bottom half handler for event(0x%02x),ack_required=%d\n" , - evt_type, ack_req); +"scheduling bottom half handler for event(0x%02x) - (0x%08x), ack_required=%d\n" , + evt_type,le32_to_cpu (event_reply->event_context), ack_req); sz = event_reply->event_data_length *4 ; fwevt =mpi3mr_alloc_fwevt (sz);if (!fwevt) {
drivers/scsi/mpi3mr/mpi3mr_transport.c +9 -2
@@ -410,9 +410,11 @@ static void mpi3mr_remove_device_by_sas_address(struct mpi3mr_ioc *mrioc, sas_address, hba_port);if (tgtdev) {if (!list_empty (&tgtdev->list)) { -list_del_init (&tgtdev->list); was_on_tgtdev_list =1 ; -mpi3mr_tgtdev_put (tgtdev); +if (tgtdev->state ==MPI3MR_DEV_REMOVE_HS_STARTED ) { +list_del_init (&tgtdev->list); +mpi3mr_tgtdev_put (tgtdev); + } } }spin_unlock_irqrestore (&mrioc->tgtdev_lock, flags);
@@ -2058,6 +2060,8 @@ int mpi3mr_expander_add(struct mpi3mr_ioc *mrioc, u16 handle) link_rate = (expander_pg1.negotiated_link_rate &MPI3_SAS_NEG_LINK_RATE_LOGICAL_MASK ) >>MPI3_SAS_NEG_LINK_RATE_LOGICAL_SHIFT ; +if (link_rate <MPI3_SAS_NEG_LINK_RATE_1_5 ) + link_rate =MPI3_SAS_NEG_LINK_RATE_1_5 ;mpi3mr_update_links (mrioc, sas_address_parent, handle, i, link_rate, hba_port); }
@@ -2367,6 +2371,9 @@ int mpi3mr_report_tgtdev_to_sas_transport(struct mpi3mr_ioc *mrioc, link_rate =mpi3mr_get_sas_negotiated_logical_linkrate (mrioc, tgtdev); +if (link_rate <MPI3_SAS_NEG_LINK_RATE_1_5 ) + link_rate =MPI3_SAS_NEG_LINK_RATE_1_5 ; +mpi3mr_update_links (mrioc, sas_address_parent, tgtdev->dev_handle, parent_phy_number, link_rate, hba_port);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2130/3318 scsi: mpi3mr: Rename log data save helper to reflect threaded/BH context
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ranjan Kumar <[email protected]>
[ Upstream commit d0d19250ed81907eac707be8221eb31e5b96b647 ]
Log data events can be processed from BH and threaded contexts. Rename the save helper to document its intended usage and improve readability of the event handling flow.
Stable-dep-of: 77554f01187d ("scsi: mpi3mr: Fix out-of-bounds read of event data")
--- drivers/scsi/mpi3mr/mpi3mr.h | 2 +- drivers/scsi/mpi3mr/mpi3mr_app.c | 4 ++-- drivers/scsi/mpi3mr/mpi3mr_os.c | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-)
drivers/scsi/mpi3mr/mpi3mr.h +1 -1
@@ -1350,7 +1350,7 @@ void mpi3mr_pel_get_seqnum_complete(struct mpi3mr_ioc *mrioc, struct mpi3mr_drv_cmd *drv_cmd);int mpi3mr_pel_get_seqnum_post (struct mpi3mr_ioc *mrioc,struct mpi3mr_drv_cmd *drv_cmd); -void mpi3mr_app_save_logdata (struct mpi3mr_ioc *mrioc,char *event_data, +void mpi3mr_app_save_logdata_th (struct mpi3mr_ioc *mrioc,char *event_data,u16 event_data_size);struct mpi3mr_enclosure_node *mpi3mr_enclosure_find_by_handle (struct mpi3mr_ioc *mrioc,u16 handle);
drivers/scsi/mpi3mr/mpi3mr_app.c +2 -2
@@ -1434,7 +1434,7 @@ static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job, unsigned int *reply }/** -* mpi3mr_app_save_logdata - Save Log Data events +* mpi3mr_app_save_logdata_th - Save Log Data events * @mrioc: Adapter instance reference * @event_data: event data associated with log data event * @event_data_size: event data size to copy
@@ -1446,7 +1446,7 @@ static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job, unsigned int *reply* * Return:Nothing */ -void mpi3mr_app_save_logdata (struct mpi3mr_ioc *mrioc,char *event_data, +void mpi3mr_app_save_logdata_th (struct mpi3mr_ioc *mrioc,char *event_data,u16 event_data_size) {u32 index = mrioc->logdata_buf_idx;
drivers/scsi/mpi3mr/mpi3mr_os.c +6 -1
@@ -1858,7 +1858,7 @@ static void mpi3mr_pcietopochg_evt_bh(struct mpi3mr_ioc *mrioc,static void mpi3mr_logdata_evt_bh (struct mpi3mr_ioc *mrioc,struct mpi3mr_fwevt *fwevt) { -mpi3mr_app_save_logdata (mrioc, fwevt->event_data, +mpi3mr_app_save_logdata_th (mrioc, fwevt->event_data, fwevt->event_data_size); }
@@ -2963,6 +2963,11 @@ void mpi3mr_os_handle_events(struct mpi3mr_ioc *mrioc, }case MPI3_EVENT_DEVICE_INFO_CHANGED :case MPI3_EVENT_LOG_DATA : + + sz = event_reply->event_data_length *4 ; +mpi3mr_app_save_logdata_th (mrioc, + (char *)event_reply->event_data, sz); +break ;case MPI3_EVENT_ENCL_DEVICE_STATUS_CHANGE :case MPI3_EVENT_ENCL_DEVICE_ADDED : {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2131/3318 scsi: mpi3mr: Fix out-of-bounds read of event data
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 77554f01187d91c20f04d2a8e28270943ed64cca ]
The event data length from the reply is used as is, both when caching log data and when sizing the buffer handed to the bottom half. A length larger than the frame makes both of them read past the end of it.
Clamp the length to what the frame can hold.
--- drivers/scsi/mpi3mr/mpi3mr_os.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_os.c +13 -3
@@ -2909,7 +2909,7 @@ void mpi3mr_add_event_wait_for_device_refresh(struct mpi3mr_ioc *mrioc)void mpi3mr_os_handle_events (struct mpi3mr_ioc *mrioc,struct mpi3_event_notification_reply *event_reply) { -u16 evt_type, sz; +u16 evt_type, sz, avail_reply_room;struct mpi3mr_fwevt *fwevt =NULL ;bool ack_req =0 , process_evt_bh =0 ;
@@ -2964,7 +2964,12 @@ void mpi3mr_os_handle_events(struct mpi3mr_ioc *mrioc,case MPI3_EVENT_DEVICE_INFO_CHANGED :case MPI3_EVENT_LOG_DATA : - sz = event_reply->event_data_length *4 ; +if (mrioc->reply_sz > offsetof(struct mpi3_event_notification_reply , event_data)) + avail_reply_room = mrioc->reply_sz - + offsetof(struct mpi3_event_notification_reply , event_data); +else + avail_reply_room =0 ; + sz =min_t (u16, event_reply->event_data_length *4 , avail_reply_room);mpi3mr_app_save_logdata_th (mrioc, (char *)event_reply->event_data, sz);break ;
@@ -2998,7 +3003,12 @@ void mpi3mr_os_handle_events(struct mpi3mr_ioc *mrioc,dprint_event_th (mrioc,"scheduling bottom half handler for event(0x%02x) - (0x%08x), ack_required=%d\n" , evt_type,le32_to_cpu (event_reply->event_context), ack_req); - sz = event_reply->event_data_length *4 ; +if (mrioc->reply_sz > offsetof(struct mpi3_event_notification_reply , event_data)) + avail_reply_room = mrioc->reply_sz - + offsetof(struct mpi3_event_notification_reply , event_data); +else + avail_reply_room =0 ; + sz =min_t (u16, event_reply->event_data_length *4 , avail_reply_room); fwevt =mpi3mr_alloc_fwevt (sz);if (!fwevt) { dprint_event_th(mrioc,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2132/3318 scsi: mpi3mr: Fix out-of-bounds phy array access on link change
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit f67caaa2521a3c8f931d1e679d831ba5ca654794 ]
The phy number that comes with a link change is used to index the node's phy array without being compared against the number of phys allocated for that node.
Check it first.
--- drivers/scsi/mpi3mr/mpi3mr_transport.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/scsi/mpi3mr/mpi3mr_transport.c +7 -0
@@ -1070,6 +1070,13 @@ void mpi3mr_update_links(struct mpi3mr_ioc *mrioc,return ; } +if (phy_number >= mr_sas_node->num_phys) { +spin_unlock_irqrestore (&mrioc->sas_node_lock, flags); +ioc_err (mrioc,"%s: phy_number(%d) >= num_phys(%d)\n" , + __func__, phy_number, mr_sas_node->num_phys); +return ; + } + mr_sas_phy = &mr_sas_node->phy[phy_number]; mr_sas_phy->attached_handle = handle;spin_unlock_irqrestore (&mrioc->sas_node_lock, flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2133/3318 scsi: mpi3mr: Fix buffer overflow in the BSG target device map
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 203b3072e7aa10d98b3f2b766693ea925cfc571d ]
The size of the target device map buffer is held in a u16 while the number of devices it is derived from is not bounded to fit. With enough devices the size wraps, a short buffer is allocated, and the loop that fills it writes past the end.
Do the calculation in size_t.
--- drivers/scsi/mpi3mr/mpi3mr_app.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_app.c +4 -3
@@ -309,7 +309,8 @@ static long mpi3mr_bsg_pel_enable(struct mpi3mr_ioc *mrioc,static long mpi3mr_get_all_tgt_info (struct mpi3mr_ioc *mrioc,struct bsg_job *job) { -u16 num_devices =0 , i =0 , size; +u16 num_devices =0 , i =0 ; +size_t size;unsigned long flags;struct mpi3mr_tgt_dev *tgtdev;struct mpi3mr_device_map_info *devmap_info =NULL ;
@@ -335,8 +336,8 @@ static long mpi3mr_get_all_tgt_info(struct mpi3mr_ioc *mrioc,return 0 ; } - kern_entrylen = num_devices *sizeof (*devmap_info); - size =sizeof (u64) + kern_entrylen; + kern_entrylen = (uint32_t )num_devices *sizeof (*devmap_info); + size =sizeof (u64) + (size_t )kern_entrylen; alltgt_info =kzalloc (size,GFP_KERNEL );if (!alltgt_info)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2134/3318 scsi: mpi3mr: Fix out-of-bounds read in PCIe topology change events
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 7d572b4dc4ed0494e67097d4b7368666655f5c99 ]
The number of entries in a PCIe topology change event is used to walk the entry array without being compared against the amount of event data that was received.
Bound the entry count to the received event data before use.
--- drivers/scsi/mpi3mr/mpi3mr_os.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_os.c +19 -3
@@ -2554,12 +2554,28 @@ static void mpi3mr_pcietopochg_evt_th(struct mpi3mr_ioc *mrioc,struct mpi3_event_data_pcie_topology_change_list *topo_evt = (struct mpi3_event_data_pcie_topology_change_list *)event_reply->event_data;int i; -u16 handle; -u8 reason_code; +u16 handle, avail_len; +u8 reason_code, max_entries, num_entries;struct mpi3mr_tgt_dev *tgtdev =NULL ;struct mpi3mr_stgt_priv_data *scsi_tgt_priv_data =NULL ; -for (i =0 ; i < topo_evt->num_entries; i++) { + avail_len = event_reply->event_data_length *4 ; +if (avail_len < offsetof(struct mpi3_event_data_pcie_topology_change_list , port_entry)) { +ioc_err (mrioc,"PCIe topology event: event data too small (%u bytes)\n" , + avail_len); +return ; + } + max_entries = (avail_len - + offsetof(struct mpi3_event_data_pcie_topology_change_list , port_entry)) / +sizeof (struct mpi3_event_pcie_topo_port_entry ); + num_entries = topo_evt->num_entries; +if (num_entries > max_entries) { +ioc_err (mrioc,"PCIe topology event: num_entries(%d) exceeds max(%d)\n" , + num_entries, max_entries); +return ; + } + +for (i =0 ; i < num_entries; i++) { handle =le16_to_cpu (topo_evt->port_entry[i].attached_dev_handle);if (!handle)continue ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2135/3318 scsi: mpi3mr: Fix use-after-free of the firmware event workqueue
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit c94c746e6c80439a4a9a0e1e20f2dae62a4d57ef ]
The enqueue path reads the workqueue pointer before taking the event lock, while the remove path clears that pointer and destroys the workqueue while holding it. The enqueue can therefore reach queue_work() after the workqueue is gone.
Move the check inside the lock.
--- drivers/scsi/mpi3mr/mpi3mr_os.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_os.c +4 -3
@@ -233,10 +233,11 @@ static void mpi3mr_fwevt_add_to_list(struct mpi3mr_ioc *mrioc, {unsigned long flags; -if (!mrioc->fwevt_worker_thread) -return ; -spin_lock_irqsave (&mrioc->fwevt_lock, flags); +if (!mrioc->fwevt_worker_thread) { +spin_unlock_irqrestore (&mrioc->fwevt_lock, flags); +return ; + }/* get fwevt reference count while adding it to fwevt_list */ mpi3mr_fwevt_get (fwevt);INIT_LIST_HEAD (&fwevt->list);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2136/3318 iio: accel: kionix-kx022a: Fix IPOL macro name
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matti Vaittinen <[email protected]>
[ Upstream commit 4a4b0d75622f7d911c96045b328fe2e88be05072 ]
The "interrupt polarity high"-macro for KX022A variant is defined as:
"#define KX022A_MASK_IPOL KX022A_MASK_IPOL1"
However, the KX022A_MASK_IPOL1 is not defined anywhere, so actually using the KX022A_IPOL_HIGH would produce a compile error.
Fix the define by using correct mask.
--- drivers/iio/accel/kionix-kx022a.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/accel/kionix-kx022a.h +1 -1
@@ -63,7 +63,7 @@#define KX022A_MASK_IEN BIT(5)#define KX022A_MASK_IPOL BIT(4)#define KX022A_IPOL_LOW 0 -#define KX022A_IPOL_HIGH KX022A_MASK_IPOL1 +#define KX022A_IPOL_HIGH KX022A_MASK_IPOL#define KX022A_MASK_ITYP BIT(3)#define KX022A_ITYP_PULSE KX022A_MASK_ITYP#define KX022A_ITYP_LEVEL 0
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2137/3318 iio: imu: adis16400: Check return value of spi_setup()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Salah Triki <[email protected]>
[ Upstream commit a7c07602e00596a45de8a4a700af96392953ed38 ]
In adis16400_initial_setup(), the return value of spi_setup() was ignored. If SPI configuration fails, the driver would proceed with the initialization anyway, leading to undefined behavior or silent failures during device setup.
Check the return value of spi_setup() and return the error code immediately if it fails.
--- drivers/iio/imu/adis16400.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/iio/imu/adis16400.c +4 -1
@@ -443,7 +443,10 @@ static int adis16400_initial_setup(struct iio_dev *indio_dev)else st->adis.spi->max_speed_hz =ADIS16400_SPI_FAST ; st->adis.spi->mode =SPI_MODE_3 ; -spi_setup (st->adis.spi); + + ret =spi_setup (st->adis.spi); +if (ret) +return ret; ret =__adis_initial_startup (&st->adis);if (ret)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2138/3318 efi/libstub: Fix efi_set_event_at() parameter documentation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit c12a3a4b35e47fd511fbd550d3637318be41c4eb ]
efi_set_event_at() documents ids although its array index argument is named idx. This produces missing and excess parameter warnings.
Match the argument name and fix the adjacent spelling of array.
--- drivers/firmware/efi/libstub/efistub.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/firmware/efi/libstub/efistub.h +2 -2
@@ -220,8 +220,8 @@ typedef void (__efiapi *efi_event_notify_t)(efi_event_t, void *);* efi_set_event_at() - add event to events array * * @events: array of UEFI events -* @ids: index where to put the event in the array -* @event: event to add to the aray +* @idx: index where to put the event in the array +* @event: event to add to the array * * boottime->wait_for_event() takes an array of events as input. * Provide a helper to set it up correctly for mixed mode.
Signature · 1 line
2.53.0