]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: mwifiex: Constify struct mwifiex_if_ops
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sun, 19 Jan 2025 17:48:39 +0000 (18:48 +0100)
committerKalle Valo <kvalo@kernel.org>
Tue, 28 Jan 2025 18:12:40 +0000 (20:12 +0200)
'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>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://patch.msgid.link/03d524b72f20a0302e4de5e0ebdc20ab69469dec.1737308889.git.christophe.jaillet@wanadoo.fr
drivers/net/wireless/marvell/mwifiex/main.c
drivers/net/wireless/marvell/mwifiex/main.h
drivers/net/wireless/marvell/mwifiex/pcie.c
drivers/net/wireless/marvell/mwifiex/sdio.c
drivers/net/wireless/marvell/mwifiex/usb.c

index 855019fe5485821b5d50bf0e96e8399956b07baf..45eecb5f643b7cb965fc74b20c70608cfbb1bfaa 100644 (file)
@@ -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 @@ err_exit:
  */
 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;
index 0674dcf7a53745b6ff16971d3bb6f2ecabfb8690..fb15831201f74b40c3226f61f969e6f0ac7dafe4 100644 (file)
@@ -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);
 
index 5f997becdbaa2579aee268ff120c983c70b93a37..e11458fd4d50fa298b9e552c8e4b6c7e6c332f3c 100644 (file)
@@ -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,
index 490ffd981164d0294204840f34c4f0f588655b16..c1fe4844883999e0aec01c9bf70b36a4c1b2151e 100644 (file)
@@ -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,
index 6085cd50970d46fe51a32b06d578a2d3c91659a6..3034c4405cb57c4a349fffdb38dc1eb6b872be42 100644 (file)
@@ -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,