peci: Constify struct peci_controller_ops
authorZev Weiss <zev@bewilderbeest.net>
Fri, 23 Jun 2023 14:28:05 +0000 (16:28 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 4 Aug 2023 14:21:30 +0000 (16:21 +0200)
As with most ops structs, we never modify it at runtime, and keeping
function pointers in read-only memory is generally a good thing
security-wise.

Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Link: https://lore.kernel.org/r/20230327224315.11135-1-zev@bewilderbeest.net
Reviewed-by: Iwona Winiarska <iwona.winiarska@intel.com>
Signed-off-by: Iwona Winiarska <iwona.winiarska@intel.com>
Link: https://lore.kernel.org/r/20230623142805.577612-1-iwona.winiarska@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/peci/controller/peci-aspeed.c
drivers/peci/core.c
include/linux/peci.h

index 731c5d8f75c66a3a4865f48e640dcd6d85a3e69f..7fdc25afcf2f44a9c17817ed2d499de08caad4f4 100644 (file)
@@ -468,7 +468,7 @@ static void aspeed_peci_property_setup(struct aspeed_peci *priv)
                                      ASPEED_PECI_CMD_TIMEOUT_MS_DEFAULT, &priv->cmd_timeout_ms);
 }
 
-static struct peci_controller_ops aspeed_ops = {
+static const struct peci_controller_ops aspeed_ops = {
        .xfer = aspeed_peci_xfer,
 };
 
index 9c8cf07e51c75d15910daf68e3b2a2323f179fe0..0f83a9c6093bc2b01f0f0cdd7f70772305cdafd0 100644 (file)
@@ -44,7 +44,7 @@ int peci_controller_scan_devices(struct peci_controller *controller)
 }
 
 static struct peci_controller *peci_controller_alloc(struct device *dev,
-                                                    struct peci_controller_ops *ops)
+                                                    const struct peci_controller_ops *ops)
 {
        struct peci_controller *controller;
        int ret;
@@ -113,7 +113,7 @@ static void unregister_controller(void *_controller)
  * Return: Pointer to the newly allocated controller or ERR_PTR() in case of failure.
  */
 struct peci_controller *devm_peci_controller_add(struct device *dev,
-                                                struct peci_controller_ops *ops)
+                                                const struct peci_controller_ops *ops)
 {
        struct peci_controller *controller;
        int ret;
index 06e6ef9352973355778ef98935fc0a9cac8999a7..9b3d36aff431e14f487db75084ed3a68ef1cdf7f 100644 (file)
@@ -42,13 +42,13 @@ struct peci_controller_ops {
  */
 struct peci_controller {
        struct device dev;
-       struct peci_controller_ops *ops;
+       const struct peci_controller_ops *ops;
        struct mutex bus_lock; /* held for the duration of xfer */
        u8 id;
 };
 
 struct peci_controller *devm_peci_controller_add(struct device *parent,
-                                                struct peci_controller_ops *ops);
+                                                const struct peci_controller_ops *ops);
 
 static inline struct peci_controller *to_peci_controller(void *d)
 {