Skip to contentSkip to conversation

wwan: iosm: use a flexible array rather than allocate short objects

PATCH Applied Jakub Kicinski 3 participants 5 messages May 20, 2022 – May 21, 2022

Subsystems (4)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH 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
index 0809ba664276..3da5ec75e0f0 100644
@@ -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
author maintainer
#1 lore raw
Quoted 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 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.

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?

#2 lore raw
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 objects

Quoted 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 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.

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.

Reviewed-by on v1 1/1
#3 lore raw
In reply to Jakub Kicinski
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 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.

#4 lore raw
In reply to Jakub Kicinski
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 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.

[...]

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