leds: trigger: panic: Don't register panic notifier if creating the trigger failed
Subsystems (4)
Sasha Levin
maintainerPATCH 1/6 leds: trigger: panic: Don't register panic notifier if creating the trigger failed
From: Heiner Kallweit <[email protected]>
[ Upstream commit afacb21834bb02785ddb0c3ec197208803b74faa ]
It doesn't make sense to register the panic notifier if creating the panic trigger failed.
--- drivers/leds/trigger/ledtrig-panic.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/leds/trigger/ledtrig-panic.c +4 -1
@@ -63,10 +63,13 @@ static long led_panic_blink(int state)static int __init ledtrig_panic_init (void ) { +led_trigger_register_simple ("panic" , &trigger); +if (!trigger) +return -ENOMEM ; +atomic_notifier_chain_register (&panic_notifier_list, &led_trigger_panic_nb); -led_trigger_register_simple ("panic" , &trigger); panic_blink = led_panic_blink;return 0 ; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 2/6 um: Fix naming clash between UML and scheduler
From: Anton Ivanov <[email protected]>
[ Upstream commit 541d4e4d435c8b9bfd29f70a1da4a2db97794e0a ]
__cant_sleep was already used and exported by the scheduler. The name had to be changed to a UML specific one.
--- arch/um/include/shared/kern_util.h | 2 +- arch/um/kernel/process.c | 2 +- arch/um/os-Linux/helper.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-)
arch/um/include/shared/kern_util.h +1 -1
@@ -49,7 +49,7 @@ extern void do_uml_exitcalls(void);* Are we disallowed to sleep? Used to choose between GFP_KERNEL and * GFP_ATOMIC. */ -extern int __cant_sleep (void ); +extern int __uml_cant_sleep (void );extern int get_current_pid (void );extern int copy_from_user_proc (void *to,void *from,int size);extern int cpu (void );
arch/um/kernel/process.c +1 -1
@@ -258,7 +258,7 @@ void arch_cpu_idle(void)local_irq_enable (); } -int __cant_sleep (void ) { +int __uml_cant_sleep (void ) {return in_atomic () ||irqs_disabled () ||in_interrupt ();/* Is in_interrupt() really needed? */ }
arch/um/os-Linux/helper.c +3 -3
@@ -45,7 +45,7 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv)unsigned long stack, sp;int pid, fds[2 ], ret, n; - stack =alloc_stack (0 ,__cant_sleep ()); + stack =alloc_stack (0 ,__uml_cant_sleep ());if (stack ==0 )return -ENOMEM ;
@@ -69,7 +69,7 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv) data.pre_data = pre_data; data.argv = argv; data.fd = fds[1 ]; - data.buf =__cant_sleep () ?uml_kmalloc (PATH_MAX ,UM_GFP_ATOMIC ) : + data.buf =__uml_cant_sleep () ?uml_kmalloc (PATH_MAX ,UM_GFP_ATOMIC ) :uml_kmalloc (PATH_MAX ,UM_GFP_KERNEL ); pid =clone (helper_child, (void *) sp,CLONE_VM , &data);if (pid <0 ) {
@@ -116,7 +116,7 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags,unsigned long stack, sp;int pid, status, err; - stack =alloc_stack (0 ,__cant_sleep ()); + stack =alloc_stack (0 ,__uml_cant_sleep ());if (stack ==0 )return -ENOMEM ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 3/6 um: Don't use vfprintf() for os_info()
In reply to Sasha LevinFrom: Benjamin Berg <[email protected]>
[ Upstream commit 236f9fe39b02c15fa5530b53e9cca48354394389 ]
The threads allocated inside the kernel have only a single page of stack. Unfortunately, the vfprintf function in standard glibc may use too much stack-space, overflowing it.
To make os_info safe to be used by helper threads, use the kernel vscnprintf function into a smallish buffer and write out the information to stderr.
--- arch/um/os-Linux/util.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
arch/um/os-Linux/util.c +17 -2
@@ -166,23 +166,38 @@ __uml_setup("quiet", quiet_cmd_param,"quiet\n" " Turns off information messages during boot.\n\n"); +/* +* The os_info/os_warn functions will be called by helper threads. These +* have a very limited stack size and using the libc formatting functions +* may overflow the stack. +* So pull in the kernel vscnprintf and use that instead with a fixed +* on-stack buffer. +*/ +int vscnprintf (char *buf,size_t size,const char *fmt,va_list args); +void os_info (const char *fmt, ...) { +char buf[256 ];va_list list; +int len;if (quiet_info)return ;va_start (list, fmt); -vfprintf (stderr, fmt, list); + len =vscnprintf (buf,sizeof (buf), fmt, list); +fwrite (buf, len,1 , stderr);va_end (list); }void os_warn (const char *fmt, ...) { +char buf[256 ];va_list list; +int len;va_start (list, fmt); -vfprintf (stderr, fmt, list); + len =vscnprintf (buf,sizeof (buf), fmt, list); +fwrite (buf, len,1 , stderr);va_end (list); }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 4/6 um: net: Fix return type of uml_net_start_xmit()
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit 7d748f60a4b82b50bf25fad1bd42d33f049f76aa ]
With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A warning in clang aims to catch these at compile time, which reveals:
arch/um/drivers/net_kern.c:353:21: warning: incompatible function pointer types initializing 'netdev_tx_t (*)(struct sk_buff *, struct net_device *)' (aka 'enum netdev_tx (*)(struct sk_buff *, struct net_device *)') with an expression of type 'int (struct sk_buff *, struct net_device *)' [-Wincompatible-function-pointer-types-strict]
353 | .ndo_start_xmit = uml_net_start_xmit,
| ^~~~~~~~~~~~~~~~~~
1 warning generated.
->ndo_start_xmit() in 'struct net_device_ops' expects a return type of 'netdev_tx_t', not 'int'. Adjust the return type of uml_net_start_xmit() to match the prototype's to resolve the warning. While UML does not currently implement support for kCFI, it could in the future, which means this warning becomes a fatal CFI failure at run time.
--- arch/um/drivers/net_kern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/um/drivers/net_kern.c +1 -1
@@ -204,7 +204,7 @@ static int uml_net_close(struct net_device *dev)return 0 ; } -static int uml_net_start_xmit (struct sk_buff *skb,struct net_device *dev) +static netdev_tx_t uml_net_start_xmit (struct sk_buff *skb,struct net_device *dev) {struct uml_net_private *lp =netdev_priv (dev);unsigned long flags;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 5/6 i3c: master: cdns: Update maximum prescaler value for i2c clock
In reply to Sasha LevinFrom: Harshit Shah <[email protected]>
[ Upstream commit 374c13f9080a1b9835a5ed3e7bea93cf8e2dc262 ]
As per the Cadence IP document fixed the I2C clock divider value limit from 16 bits instead of 10 bits. Without this change setting up the I2C clock to low frequencies will not work as the prescaler value might be greater than 10 bit number.
I3C clock divider value is 10 bits only. Updating the macro names for both.
--- drivers/i3c/master/i3c-master-cdns.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/i3c/master/i3c-master-cdns.c +4 -3
@@ -74,7 +74,8 @@#define PRESCL_CTRL0 0x14#define PRESCL_CTRL0_I2C (x) ((x) << 16)#define PRESCL_CTRL0_I3C (x) (x) -#define PRESCL_CTRL0_MAX GENMASK(9, 0) +#define PRESCL_CTRL0_I3C_MAX GENMASK(9, 0) +#define PRESCL_CTRL0_I2C_MAX GENMASK(15, 0)#define PRESCL_CTRL1 0x18#define PRESCL_CTRL1_PP_LOW_MASK GENMASK(15, 8)
@@ -1212,7 +1213,7 @@ static int cdns_i3c_master_bus_init(struct i3c_master_controller *m)return -EINVAL ; pres =DIV_ROUND_UP (sysclk_rate, (bus->scl_rate.i3c *4 )) -1 ; -if (pres >PRESCL_CTRL0_MAX ) +if (pres >PRESCL_CTRL0_I3C_MAX )return -ERANGE ; bus->scl_rate.i3c = sysclk_rate / ((pres +1 ) *4 );
@@ -1225,7 +1226,7 @@ static int cdns_i3c_master_bus_init(struct i3c_master_controller *m) max_i2cfreq = bus->scl_rate.i2c; pres = (sysclk_rate / (max_i2cfreq *5 )) -1 ; -if (pres >PRESCL_CTRL0_MAX ) +if (pres >PRESCL_CTRL0_I2C_MAX )return -ERANGE ; bus->scl_rate.i2c = sysclk_rate / ((pres +1 ) *5 );
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 6/6 mfd: ti_am335x_tscadc: Fix TI SoC dependencies
In reply to Sasha LevinFrom: Peter Robinson <[email protected]>
[ Upstream commit 284d16c456e5d4b143f375b8ccc4038ab3f4ee0f ]
The ti_am335x_tscadc is specific to some TI SoCs, update the dependencies for those SoCs and compile testing.
--- drivers/mfd/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/mfd/Kconfig +1 -0
@@ -1299,6 +1299,7 @@ config MFD_DAVINCI_VOICECODEC config MFD_TI_AM335X_TSCADC tristate "TI ADC / Touch Screen chip support" + depends on ARCH_OMAP2PLUS || ARCH_K3 || COMPILE_TEST select MFD_CORE select REGMAP select REGMAP_MMIO
Signature · 1 line
2.43.0