Re: [PATCH v4 44/45] mm: fs: initialize fsdata passed to write_begin/write_end interface

From: Matthew Wilcox
Date: Mon Jul 04 2022 - 16:08:45 EST


On Fri, Jul 01, 2022 at 04:23:09PM +0200, Alexander Potapenko wrote:
> Functions implementing the a_ops->write_end() interface accept the
> `void *fsdata` parameter that is supposed to be initialized by the
> corresponding a_ops->write_begin() (which accepts `void **fsdata`).
>
> However not all a_ops->write_begin() implementations initialize `fsdata`
> unconditionally, so it may get passed uninitialized to a_ops->write_end(),
> resulting in undefined behavior.

... wait, passing an uninitialised variable to a function *which doesn't
actually use it* is now UB? What genius came up with that rule? What
purpose does it serve?