Skip to content

Commit 9eec1fc

Browse files
srishanmalexdeucher
authored andcommitted
drm/radeon: Prefer strscpy over strlcpy in 'radeon_combios_get_power_modes'
strlcpy() reads the entire source buffer first. This read may exceed the destination size limit. This is both inefficient and can lead to linear read overflows if a source string is not NUL-terminated. The safe replacement is strscpy() [1]. cleanup to remove the strlcpy() function entirely from the kernel [2]. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy [2] KSPP#89 Fixes the following: WARNING: Prefer strscpy over strlcpy + strlcpy(info.type, name, sizeof(info.type)); WARNING: Prefer strscpy over strlcpy + strlcpy(info.type, name, sizeof(info.type)); Cc: Guchun Chen <[email protected]> Cc: Christian König <[email protected]> Cc: Alex Deucher <[email protected]> Signed-off-by: Srinivasan Shanmugam <[email protected]> Reviewed-by: Alex Deucher <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 6cf2021 commit 9eec1fc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/gpu/drm/radeon/radeon_combios.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2702,7 +2702,7 @@ void radeon_combios_get_power_modes(struct radeon_device *rdev)
27022702
struct i2c_board_info info = { };
27032703
const char *name = thermal_controller_names[thermal_controller];
27042704
info.addr = i2c_addr >> 1;
2705-
strlcpy(info.type, name, sizeof(info.type));
2705+
strscpy(info.type, name, sizeof(info.type));
27062706
i2c_new_client_device(&rdev->pm.i2c_bus->adapter, &info);
27072707
}
27082708
}
@@ -2719,7 +2719,7 @@ void radeon_combios_get_power_modes(struct radeon_device *rdev)
27192719
struct i2c_board_info info = { };
27202720
const char *name = "f75375";
27212721
info.addr = 0x28;
2722-
strlcpy(info.type, name, sizeof(info.type));
2722+
strscpy(info.type, name, sizeof(info.type));
27232723
i2c_new_client_device(&rdev->pm.i2c_bus->adapter, &info);
27242724
DRM_INFO("Possible %s thermal controller at 0x%02x\n",
27252725
name, info.addr);

0 commit comments

Comments
 (0)