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

drivers: misc: sram: fix up some const issues with recent attribute changes

The binary attribute const changes recently for the sram driver were
made in a way that hid the fact that we would be casting a const pointer
to a non-const one. So explicitly make the cast so that it is obvious
and preserve the const pointer in the sram_reserve_cmp() function.

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Thomas Weißschuh <linux@weissschuh.net>
Fixes: c3b8c358c4f3 ("misc: sram: constify 'struct bin_attribute'")
Link: https://lore.kernel.org/r/2025052125-squid-sandstorm-a418@gregkh
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+6 -4
+6 -4
drivers/misc/sram.c
··· 28 28 { 29 29 struct sram_partition *part; 30 30 31 - part = container_of(attr, struct sram_partition, battr); 31 + /* Cast away the const as the attribute is part of a larger structure */ 32 + part = (struct sram_partition *)container_of(attr, struct sram_partition, battr); 32 33 33 34 mutex_lock(&part->lock); 34 35 memcpy_fromio(buf, part->base + pos, count); ··· 44 43 { 45 44 struct sram_partition *part; 46 45 47 - part = container_of(attr, struct sram_partition, battr); 46 + /* Cast away the const as the attribute is part of a larger structure */ 47 + part = (struct sram_partition *)container_of(attr, struct sram_partition, battr); 48 48 49 49 mutex_lock(&part->lock); 50 50 memcpy_toio(part->base + pos, buf, count); ··· 166 164 static int sram_reserve_cmp(void *priv, const struct list_head *a, 167 165 const struct list_head *b) 168 166 { 169 - struct sram_reserve *ra = list_entry(a, struct sram_reserve, list); 170 - struct sram_reserve *rb = list_entry(b, struct sram_reserve, list); 167 + const struct sram_reserve *ra = list_entry(a, struct sram_reserve, list); 168 + const struct sram_reserve *rb = list_entry(b, struct sram_reserve, list); 171 169 172 170 return ra->start - rb->start; 173 171 }