public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers: pci: Fix flexible array usage
@ 2025-02-10 13:27 Purva Yeshi
  2025-02-10 22:47 ` Bjorn Helgaas
  2025-02-10 23:03 ` Keith Busch
  0 siblings, 2 replies; 9+ messages in thread
From: Purva Yeshi @ 2025-02-10 13:27 UTC (permalink / raw)
  To: bhelgaas; +Cc: skhan, linux-pci, linux-kernel, Purva Yeshi

Fix warning detected by smatch tool:
Array of flexible structure occurs in 'pci_saved_state' struct

The warning occurs because struct pci_saved_state contains struct
pci_cap_saved_data cap[], where cap[] has a flexible array member (data[]).
Arrays of structures with flexible members are not allowed, leading to this
warning.

Replaced cap[] with a pointer (*cap), allowing dynamic memory allocation
instead of embedding an invalid array of flexible structures.

Signed-off-by: Purva Yeshi <purvayeshi550@gmail.com>
---
 drivers/pci/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 869d204a7..648a080ef 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1929,7 +1929,7 @@ EXPORT_SYMBOL(pci_restore_state);
 
 struct pci_saved_state {
 	u32 config_space[16];
-	struct pci_cap_saved_data cap[];
+	struct pci_cap_saved_data *cap;
 };
 
 /**
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-02-13 14:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-10 13:27 [PATCH] drivers: pci: Fix flexible array usage Purva Yeshi
2025-02-10 22:47 ` Bjorn Helgaas
2025-02-10 23:03 ` Keith Busch
2025-02-11 21:02   ` Bjorn Helgaas
2025-02-11 21:18     ` Keith Busch
2025-02-13 10:48       ` Purva Yeshi
2025-02-13 14:41       ` Ilpo Järvinen
2025-02-13 10:42     ` Purva Yeshi
2025-02-13 10:37   ` Purva Yeshi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox