Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mfd: syscon: Add check for invalid resource size

Add a consistency check to avoid assigning an invalid value to
max_register due to a possible DT misconfiguration.

Suggested-by: Mark Langsdorf <mlangsdo@redhat.com>
Signed-off-by: Eder Zulian <ezulian@redhat.com>
Link: https://lore.kernel.org/r/20250212184524.585882-1-ezulian@redhat.com
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Eder Zulian and committed by
Lee Jones
ba09916e 860e9806

+8 -1
+8 -1
drivers/mfd/syscon.c
··· 47 47 struct regmap_config syscon_config = syscon_regmap_config; 48 48 struct resource res; 49 49 struct reset_control *reset; 50 + resource_size_t res_size; 50 51 51 52 WARN_ON(!mutex_is_locked(&syscon_list_lock)); 52 53 ··· 97 96 } 98 97 } 99 98 99 + res_size = resource_size(&res); 100 + if (res_size < reg_io_width) { 101 + ret = -EFAULT; 102 + goto err_regmap; 103 + } 104 + 100 105 syscon_config.name = kasprintf(GFP_KERNEL, "%pOFn@%pa", np, &res.start); 101 106 if (!syscon_config.name) { 102 107 ret = -ENOMEM; ··· 110 103 } 111 104 syscon_config.reg_stride = reg_io_width; 112 105 syscon_config.val_bits = reg_io_width * 8; 113 - syscon_config.max_register = resource_size(&res) - reg_io_width; 106 + syscon_config.max_register = res_size - reg_io_width; 114 107 if (!syscon_config.max_register) 115 108 syscon_config.max_register_is_0 = true; 116 109