Thread (10 messages) 10 messages, 3 authors, 2022-02-23

Re: [RFT PATCH 0/3] Fix kfree() of const memory on setting driver_override

From: Krzysztof Kozlowski <hidden>
Date: 2022-02-22 14:07:02
Also in: alsa-devel, linux-arm-msm, linux-clk, linux-remoteproc, lkml

On 22/02/2022 14:51, Rasmus Villemoes wrote:
On 22/02/2022 14.27, Krzysztof Kozlowski wrote:
quoted
Hi,

Drivers still seem to use driver_override incorrectly. Perhaps my old
patch makes sense now?
https://lore.kernel.org/all/1550484960-2392-3-git-send-email-krzk@kernel.org/ (local)

Not tested - please review and test (e.g. by writing to dirver_override
sysfs entry with KASAN enabled).
Perhaps it would make sense to update the core code to release using
kfree_const(), allowing drivers to set the initial value with
kstrdup_const(). Drivers that currently use kstrdup() or kasprintf()
will continue to work [but if they kstrdup() a string literal they could
be changed to use kstrdup_const].
The core here means several buses, so the change would not be that
small. However I don't see the reason why "driver_override" is special
and should be freed with kfree_const() while most of other places don't
use it.

The driver_override field definition is here obvious: "char *", so any
assignments of "const char *" are logically wrong (although GCC does not
warn of this literal string const discarding). Adding kfree_const() is
hiding the problem - someone did not read the definition of assigned field.

Best regards,
Krzysztof

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help