Thread (17 messages) 17 messages, 2 authors, 2021-01-21

Re: [PATCH v4 1/9] mmc: add basic support for inline encryption

From: Eric Biggers <ebiggers@kernel.org>
Date: 2021-01-21 07:47:00
Also in: linux-arm-msm, linux-fscrypt, linux-mmc

On Tue, Jan 19, 2021 at 12:52:00PM -0800, Eric Biggers wrote:
quoted
To free up the data structures, blk_ksm_destroy() is called from
mmc_free_host().

To me, this can be made more consistent. For example, it looks like
blk_ksm_destroy() could be called, even if blk_ksm_init() hasn't been
called (depending on the probe error path of the mmc host).
blk_ksm_destroy() is a no-op on an all-zeroed struct, so it's fine to call it
unnecessarily.  We could call it unconditionally, if that would be clearer.
quoted
There are a couple of options to better deal with this.
1) Extend the blk_ksm interface with a devm_blk_ksm_init() function
(thus let it deal with lifecycle problems for us) and simply drop the
call to blk_ksm_destroy().
This would require adding APIs to devm to support zeroing buffers on free and to
use kvmalloc() instead of kmalloc().  It looks like these new APIs wouldn't be
useful for many drivers (since almost everyone else just wants regular kmalloc
with no special behavior on free), so they don't seem worth adding yet.
Actually devres is more flexible than I thought; it's possible to register
custom actions to be executed.  I'll send out a patchset that adds
devm_blk_ksm_init() and converts the UFS driver to use it.

- Eric
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help