Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

peci: Constify struct peci_controller_ops

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>

authored by

Zev Weiss and committed by
Greg Kroah-Hartman
8306d6f3 a436194d

+5 -5
+1 -1
drivers/peci/controller/peci-aspeed.c
··· 468 468 ASPEED_PECI_CMD_TIMEOUT_MS_DEFAULT, &priv->cmd_timeout_ms); 469 469 } 470 470 471 - static struct peci_controller_ops aspeed_ops = { 471 + static const struct peci_controller_ops aspeed_ops = { 472 472 .xfer = aspeed_peci_xfer, 473 473 }; 474 474
+2 -2
drivers/peci/core.c
··· 44 44 } 45 45 46 46 static struct peci_controller *peci_controller_alloc(struct device *dev, 47 - struct peci_controller_ops *ops) 47 + const struct peci_controller_ops *ops) 48 48 { 49 49 struct peci_controller *controller; 50 50 int ret; ··· 113 113 * Return: Pointer to the newly allocated controller or ERR_PTR() in case of failure. 114 114 */ 115 115 struct peci_controller *devm_peci_controller_add(struct device *dev, 116 - struct peci_controller_ops *ops) 116 + const struct peci_controller_ops *ops) 117 117 { 118 118 struct peci_controller *controller; 119 119 int ret;
+2 -2
include/linux/peci.h
··· 42 42 */ 43 43 struct peci_controller { 44 44 struct device dev; 45 - struct peci_controller_ops *ops; 45 + const struct peci_controller_ops *ops; 46 46 struct mutex bus_lock; /* held for the duration of xfer */ 47 47 u8 id; 48 48 }; 49 49 50 50 struct peci_controller *devm_peci_controller_add(struct device *parent, 51 - struct peci_controller_ops *ops); 51 + const struct peci_controller_ops *ops); 52 52 53 53 static inline struct peci_controller *to_peci_controller(void *d) 54 54 {