printk: Fix signed integer overflow when defining LOG_BUF_LEN_MAX
Sasha Levin
maintainerPATCH 1/2 printk: Fix signed integer overflow when defining LOG_BUF_LEN_MAX
From: Kuan-Wei Chiu <[email protected]>
[ Upstream commit 3d6f83df8ff2d5de84b50377e4f0d45e25311c7a ]
Shifting 1 << 31 on a 32-bit int causes signed integer overflow, which leads to undefined behavior. To prevent this, cast 1 to u32 before performing the shift, ensuring well-defined behavior.
This change explicitly avoids any potential overflow by ensuring that the shift occurs on an unsigned 32-bit integer.
--- kernel/printk/printk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/printk/printk.c +1 -1
@@ -457,7 +457,7 @@ static u32 clear_idx;/* record buffer */ #define LOG_ALIGN __alignof__(struct printk_log)#define __LOG_BUF_LEN (1 << CONFIG_LOG_BUF_SHIFT) -#define LOG_BUF_LEN_MAX (u32)(1 << 31) +#define LOG_BUF_LEN_MAX ((u32)1 << 31)static char __log_buf[__LOG_BUF_LEN]__aligned(LOG_ALIGN) ;static char *log_buf = __log_buf;static u32 log_buf_len = __LOG_BUF_LEN;
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 2/2 drm/sti: hdmi: use eld_mutex to protect access to connector->eld
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit e99c0b517bcd53cf61f998a3c4291333401cb391 ]
Reading access to connector->eld can happen at the same time the drm_edid_to_eld() updates the data. Take the newly added eld_mutex in order to protect connector->eld from concurrent access.
--- drivers/gpu/drm/sti/sti_hdmi.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/sti/sti_hdmi.c +2 -0
@@ -1214,7 +1214,9 @@ static int hdmi_audio_get_eld(struct device *dev, void *data, uint8_t *buf, sizestruct drm_connector *connector = hdmi->drm_connector;DRM_DEBUG_DRIVER ("\n" ); +mutex_lock (&connector->eld_mutex);memcpy (buf, connector->eld,min (sizeof (connector->eld), len)); +mutex_unlock (&connector->eld_mutex);return 0 ; }
Signature · 1 line
2.39.5