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

Configure Feed

Select the types of activity you want to include in your feed.

usbip: vudc: Constify 'struct bin_attribute'

The sysfs core now allows instances of 'struct bin_attribute' to be
moved into read-only memory. Make use of that to protect them against
accidental or malicious modifications.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20241222-sysfs-const-bin_attr-usbip-v1-1-20d611a9bfa4@weissschuh.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Thomas Weißschuh and committed by
Greg Kroah-Hartman
997a6e14 aa13b9d5

+4 -4
+4 -4
drivers/usb/usbip/vudc_sysfs.c
··· 67 67 * Exposes device descriptor from the gadget driver. 68 68 */ 69 69 static ssize_t dev_desc_read(struct file *file, struct kobject *kobj, 70 - struct bin_attribute *attr, char *out, 70 + const struct bin_attribute *attr, char *out, 71 71 loff_t off, size_t count) 72 72 { 73 73 struct device *dev = kobj_to_dev(kobj); ··· 88 88 spin_unlock_irqrestore(&udc->lock, flags); 89 89 return ret; 90 90 } 91 - static BIN_ATTR_RO(dev_desc, sizeof(struct usb_device_descriptor)); 91 + static const BIN_ATTR_RO(dev_desc, sizeof(struct usb_device_descriptor)); 92 92 93 93 static ssize_t usbip_sockfd_store(struct device *dev, 94 94 struct device_attribute *attr, ··· 252 252 NULL, 253 253 }; 254 254 255 - static struct bin_attribute *dev_bin_attrs[] = { 255 + static const struct bin_attribute *const dev_bin_attrs[] = { 256 256 &bin_attr_dev_desc, 257 257 NULL, 258 258 }; 259 259 260 260 static const struct attribute_group vudc_attr_group = { 261 261 .attrs = dev_attrs, 262 - .bin_attrs = dev_bin_attrs, 262 + .bin_attrs_new = dev_bin_attrs, 263 263 }; 264 264 265 265 const struct attribute_group *vudc_groups[] = {