]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
iio: iio-mux: kzalloc instead of devm_kzalloc to ensure page alignment
authorMatteo Martelli <matteomartelli3@gmail.com>
Mon, 2 Dec 2024 15:11:08 +0000 (16:11 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 4 Jan 2025 14:48:17 +0000 (14:48 +0000)
commit577a66e2e634f712384c57a98f504c44ea4b47da
tree3f67b481ee1a0668b62bf6096e932018126a600b
parentf5ab868af55ff58f7783d08d674bb373cb672210
iio: iio-mux: kzalloc instead of devm_kzalloc to ensure page alignment

During channel configuration, the iio-mux driver allocates a page with
devm_kzalloc(PAGE_SIZE) to read channel ext_info. However, the resulting
buffer points to an offset of the page due to the devres header sitting
at the beginning of the allocated area. This leads to failure in the
provider driver when sysfs_emit* helpers are used to format the ext_info
attributes.

Switch to plain kzalloc version. The devres version is not strictly
necessary as the buffer is only accessed during the channel
configuration phase. Rely on __free cleanup to deallocate the buffer.
Also, move the ext_info handling into a new function to have the page
buffer definition and assignment in one statement as suggested by
cleanup documentation.

Signed-off-by: Matteo Martelli <matteomartelli3@gmail.com>
Fixes: 7ba9df54b091 ("iio: multiplexer: new iio category and iio-mux driver")
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20241202-iio-kmalloc-align-v1-2-aa9568c03937@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/multiplexer/iio-mux.c