* [PATCH] wifi: mwifiex: Constify struct mwifiex_if_ops
@ 2025-01-19 17:48 Christophe JAILLET
2025-01-28 18:12 ` Kalle Valo
2025-03-07 9:29 ` Francesco Dolcini
0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2025-01-19 17:48 UTC (permalink / raw)
To: Brian Norris, Francesco Dolcini, Kalle Valo
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-wireless
'struct mwifiex_if_ops' are not modified in these drivers.
Constifying these structures moves some data to a read-only section, so
increase overall security, especially when the structure holds some
function pointers.
On a x86_64, with allmodconfig, as an example:
Before:
======
text data bss dec hex filename
61439 4367 32 65838 1012e drivers/net/wireless/marvell/mwifiex/pcie.o
After:
=====
text data bss dec hex filename
61699 4127 32 65858 10142 drivers/net/wireless/marvell/mwifiex/pcie.o
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested-only.
---
drivers/net/wireless/marvell/mwifiex/main.c | 4 ++--
drivers/net/wireless/marvell/mwifiex/main.h | 2 +-
drivers/net/wireless/marvell/mwifiex/pcie.c | 4 ++--
drivers/net/wireless/marvell/mwifiex/sdio.c | 4 ++--
drivers/net/wireless/marvell/mwifiex/usb.c | 4 ++--
5 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/net/wireless/marvell/mwifiex/main.c b/drivers/net/wireless/marvell/mwifiex/main.c
index 855019fe5485..45eecb5f643b 100644
--- a/drivers/net/wireless/marvell/mwifiex/main.c
+++ b/drivers/net/wireless/marvell/mwifiex/main.c
@@ -54,7 +54,7 @@ const u16 mwifiex_1d_to_wmm_queue[8] = { 1, 0, 0, 1, 2, 2, 3, 3 };
* proper cleanup before exiting.
*/
static int mwifiex_register(void *card, struct device *dev,
- struct mwifiex_if_ops *if_ops, void **padapter)
+ const struct mwifiex_if_ops *if_ops, void **padapter)
{
struct mwifiex_adapter *adapter;
int i;
@@ -1713,7 +1713,7 @@ static void mwifiex_probe_of(struct mwifiex_adapter *adapter)
*/
int
mwifiex_add_card(void *card, struct completion *fw_done,
- struct mwifiex_if_ops *if_ops, u8 iface_type,
+ const struct mwifiex_if_ops *if_ops, u8 iface_type,
struct device *dev)
{
struct mwifiex_adapter *adapter;
diff --git a/drivers/net/wireless/marvell/mwifiex/main.h b/drivers/net/wireless/marvell/mwifiex/main.h
index 0674dcf7a537..fb15831201f7 100644
--- a/drivers/net/wireless/marvell/mwifiex/main.h
+++ b/drivers/net/wireless/marvell/mwifiex/main.h
@@ -1470,7 +1470,7 @@ int mwifiex_init_shutdown_fw(struct mwifiex_private *priv,
u32 func_init_shutdown);
int mwifiex_add_card(void *card, struct completion *fw_done,
- struct mwifiex_if_ops *if_ops, u8 iface_type,
+ const struct mwifiex_if_ops *if_ops, u8 iface_type,
struct device *dev);
int mwifiex_remove_card(struct mwifiex_adapter *adapter);
diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c
index 5f997becdbaa..e11458fd4d50 100644
--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
@@ -21,7 +21,7 @@
#define PCIE_VERSION "1.0"
#define DRV_NAME "Marvell mwifiex PCIe"
-static struct mwifiex_if_ops pcie_ops;
+static const struct mwifiex_if_ops pcie_ops;
static const struct mwifiex_pcie_card_reg mwifiex_reg_8766 = {
.cmd_addr_lo = PCIE_SCRATCH_0_REG,
@@ -3240,7 +3240,7 @@ static void mwifiex_pcie_down_dev(struct mwifiex_adapter *adapter)
mwifiex_pcie_free_buffers(adapter);
}
-static struct mwifiex_if_ops pcie_ops = {
+static const struct mwifiex_if_ops pcie_ops = {
.init_if = mwifiex_init_pcie,
.cleanup_if = mwifiex_cleanup_pcie,
.check_fw_status = mwifiex_check_fw_status,
diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.c b/drivers/net/wireless/marvell/mwifiex/sdio.c
index 490ffd981164..c1fe48448839 100644
--- a/drivers/net/wireless/marvell/mwifiex/sdio.c
+++ b/drivers/net/wireless/marvell/mwifiex/sdio.c
@@ -21,7 +21,7 @@
static void mwifiex_sdio_work(struct work_struct *work);
-static struct mwifiex_if_ops sdio_ops;
+static const struct mwifiex_if_ops sdio_ops;
static const struct mwifiex_sdio_card_reg mwifiex_reg_sd87xx = {
.start_rd_port = 1,
@@ -3167,7 +3167,7 @@ static void mwifiex_sdio_up_dev(struct mwifiex_adapter *adapter)
dev_err(&card->func->dev, "error enabling SDIO port\n");
}
-static struct mwifiex_if_ops sdio_ops = {
+static const struct mwifiex_if_ops sdio_ops = {
.init_if = mwifiex_init_sdio,
.cleanup_if = mwifiex_cleanup_sdio,
.check_fw_status = mwifiex_check_fw_status,
diff --git a/drivers/net/wireless/marvell/mwifiex/usb.c b/drivers/net/wireless/marvell/mwifiex/usb.c
index 6085cd50970d..3034c4405cb5 100644
--- a/drivers/net/wireless/marvell/mwifiex/usb.c
+++ b/drivers/net/wireless/marvell/mwifiex/usb.c
@@ -10,7 +10,7 @@
#define USB_VERSION "1.0"
-static struct mwifiex_if_ops usb_ops;
+static const struct mwifiex_if_ops usb_ops;
static const struct usb_device_id mwifiex_usb_table[] = {
/* 8766 */
@@ -1585,7 +1585,7 @@ mwifiex_pm_wakeup_card_complete(struct mwifiex_adapter *adapter)
return 0;
}
-static struct mwifiex_if_ops usb_ops = {
+static const struct mwifiex_if_ops usb_ops = {
.register_dev = mwifiex_register_dev,
.unregister_dev = mwifiex_unregister_dev,
.wakeup = mwifiex_pm_wakeup_card,
--
2.48.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] wifi: mwifiex: Constify struct mwifiex_if_ops
2025-01-19 17:48 [PATCH] wifi: mwifiex: Constify struct mwifiex_if_ops Christophe JAILLET
@ 2025-01-28 18:12 ` Kalle Valo
2025-03-07 9:29 ` Francesco Dolcini
1 sibling, 0 replies; 3+ messages in thread
From: Kalle Valo @ 2025-01-28 18:12 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Brian Norris, Francesco Dolcini, linux-kernel, kernel-janitors,
Christophe JAILLET, linux-wireless
Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote:
> 'struct mwifiex_if_ops' are not modified in these drivers.
>
> Constifying these structures moves some data to a read-only section, so
> increase overall security, especially when the structure holds some
> function pointers.
>
> On a x86_64, with allmodconfig, as an example:
> Before:
> ======
> text data bss dec hex filename
> 61439 4367 32 65838 1012e drivers/net/wireless/marvell/mwifiex/pcie.o
>
> After:
> =====
> text data bss dec hex filename
> 61699 4127 32 65858 10142 drivers/net/wireless/marvell/mwifiex/pcie.o
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Patch applied to wireless-next.git, thanks.
e50e30fa966e wifi: mwifiex: Constify struct mwifiex_if_ops
--
https://patchwork.kernel.org/project/linux-wireless/patch/03d524b72f20a0302e4de5e0ebdc20ab69469dec.1737308889.git.christophe.jaillet@wanadoo.fr/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] wifi: mwifiex: Constify struct mwifiex_if_ops
2025-01-19 17:48 [PATCH] wifi: mwifiex: Constify struct mwifiex_if_ops Christophe JAILLET
2025-01-28 18:12 ` Kalle Valo
@ 2025-03-07 9:29 ` Francesco Dolcini
1 sibling, 0 replies; 3+ messages in thread
From: Francesco Dolcini @ 2025-03-07 9:29 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Brian Norris, Francesco Dolcini, Kalle Valo, linux-kernel,
kernel-janitors, linux-wireless
On Sun, Jan 19, 2025 at 06:48:39PM +0100, Christophe JAILLET wrote:
> 'struct mwifiex_if_ops' are not modified in these drivers.
>
> Constifying these structures moves some data to a read-only section, so
> increase overall security, especially when the structure holds some
> function pointers.
>
> On a x86_64, with allmodconfig, as an example:
> Before:
> ======
> text data bss dec hex filename
> 61439 4367 32 65838 1012e drivers/net/wireless/marvell/mwifiex/pcie.o
>
> After:
> =====
> text data bss dec hex filename
> 61699 4127 32 65858 10142 drivers/net/wireless/marvell/mwifiex/pcie.o
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Francesco Dolcini <francesco.dolcini@toradex.com>
> Compile tested-only.
I did also a brief smoke test on 88W8997, and the driver just probe fines.
Tested-by: Francesco Dolcini <francesco.dolcini@toradex.com> # Verdin iMX8MM - 88W8997
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-07 9:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-19 17:48 [PATCH] wifi: mwifiex: Constify struct mwifiex_if_ops Christophe JAILLET
2025-01-28 18:12 ` Kalle Valo
2025-03-07 9:29 ` Francesco Dolcini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®