wwan: iosm: use a flexible array rather than allocate short objects
Subsystems (4)
Jakub Kicinski
maintainerPATCH 1/1 wwan: iosm: use a flexible array rather than allocate short objects
GCC array-bounds warns that ipc_coredump_get_list() under-allocates the size of struct iosm_cd_table *cd_table.
This is avoidable - we just need a flexible array. Nothing calls sizeof() on struct iosm_cd_list or anything that contains it.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- drivers/net/wwan/iosm/iosm_ipc_coredump.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/net/wwan/iosm/iosm_ipc_coredump.h +1 -4
@@ -14,9 +14,6 @@/* Max buffer allocated to receive coredump data */ #define MAX_DATA_SIZE 0x00010000 -/* Max number of file entries */ -#define MAX_NOF_ENTRY 256 -/* Max length */ #define MAX_SIZE_LEN 32
@@ -38,7 +35,7 @@ struct iosm_cd_list_entry {*/ struct iosm_cd_list {__le32 num_entries; -struct iosm_cd_list_entry entry[MAX_NOF_ENTRY ]; +struct iosm_cd_list_entry entry[]; } __packed;/**
Signature · 1 line
2.34.3
Jakub Kicinski
maintainerQuoted 7 lines · On Thu, 19 May 2022 23:00:13 -0700 Jakub Kicinski wrote:
GCC array-bounds warns that
ipc_coredump_get_list()under-allocates the size of structiosm_cd_table*cd_table.This is avoidable - we just need a flexible array. Nothing calls
sizeof()on structiosm_cd_listor anything that contains it.Signed-off-by Jakub Kicinski <[email protected]>
Coincidentally IDK if this:
int ipc_coredump_get_list(struct iosm_devlink *devlink, u16 cmd)
if (byte_read != MAX_CD_LIST_SIZE) goto cd_init_fail;
shouldn't set ret before jumping? Maybe set it to 0 if it's okay for it to be zero to make that clear?
Quoted 22 lines
-----Original Message-----
From: Jakub Kicinski <[email protected]>
Sent: Friday, May 20, 2022 11:34 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Kumar, M Chetan <[email protected]>; linuxwwan <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH net-next] wwan: iosm: use a flexible array rather than allocate short objectsQuoted 7 lines · On Thu, 19 May 2022 23:00:13 -0700 Jakub Kicinski wrote:
GCC array-bounds warns that
ipc_coredump_get_list()under-allocates the size of structiosm_cd_table*cd_table.This is avoidable - we just need a flexible array. Nothing calls
sizeof()on structiosm_cd_listor anything that contains it.Signed-off-by Jakub Kicinski <[email protected]>Coincidentally IDK if this:
Quoted 7 lines
int
ipc_coredump_get_list(struct iosm_devlink *devlink, u16 cmd)if (byte_read != MAX_CD_LIST_SIZE) goto cd_init_fail;shouldn't set ret before jumping? Maybe set it to 0 if it's okay for it to be zero to make that clear?
This is a redundant check we can remove it.
If the byte_read is less than MAX_CD_LIST_SIZE an error is returned as part of previous ret check.
Quoted 12 lines
-----Original Message-----
From: Jakub Kicinski <[email protected]>
Sent: Friday, May 20, 2022 11:30 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Jakub Kicinski <[email protected]>; Kumar, M Chetan <[email protected]>; linuxwwan <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: [PATCH net-next] wwan: iosm: use a flexible array rather than allocate short objects
Quoted 7 lines
GCC array-bounds warns that
ipc_coredump_get_list()under-allocates the size of structiosm_cd_table*cd_table.This is avoidable - we just need a flexible array. Nothing calls
sizeof()on structiosm_cd_listor anything that contains it.Signed-off-by Jakub Kicinski <[email protected]>
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Thu, 19 May 2022 23:00:13 -0700 you wrote:
GCC array-bounds warns that
ipc_coredump_get_list()under-allocates the size of structiosm_cd_table*cd_table.This is avoidable - we just need a flexible array. Nothing calls
sizeof()on structiosm_cd_listor anything that contains it.Signed-off-by Jakub Kicinski <[email protected]>[...]
Here is the summary with links:
- [net-next] wwan: iosm: use a flexible array rather than allocate short objects
https://git.kernel.org/netdev/net-next/c/eac67d83bf25
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html