* [PATCH] dm: add missing unlock on in dm_keyslot_evict()
@ 2025-04-30 8:05 Dan Carpenter
2025-04-30 16:50 ` Eric Biggers
0 siblings, 1 reply; 6+ messages in thread
From: Dan Carpenter @ 2025-04-30 8:05 UTC (permalink / raw)
To: Satya Tangirala
Cc: Alasdair Kergon, Mike Snitzer, Mikulas Patocka, Eric Biggers,
dm-devel, linux-kernel, kernel-janitors
We need to call dm_put_live_table() even if dm_get_live_table() returns
NULL.
Fixes: 9355a9eb21a5 ("dm: support key eviction from keyslot managers of underlying devices")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/md/dm-table.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 933e01f3fab4..1a7e2623069b 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -1177,7 +1177,7 @@ static int dm_keyslot_evict(struct blk_crypto_profile *profile,
t = dm_get_live_table(md, &srcu_idx);
if (!t)
- return 0;
+ goto put_live_table;
for (unsigned int i = 0; i < t->num_targets; i++) {
struct dm_target *ti = dm_table_get_target(t, i);
@@ -1188,6 +1188,7 @@ static int dm_keyslot_evict(struct blk_crypto_profile *profile,
(void *)key);
}
+put_live_table:
dm_put_live_table(md, srcu_idx);
return 0;
}
--
2.47.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] dm: add missing unlock on in dm_keyslot_evict()
2025-04-30 8:05 [PATCH] dm: add missing unlock on in dm_keyslot_evict() Dan Carpenter
@ 2025-04-30 16:50 ` Eric Biggers
2025-04-30 17:40 ` Dan Carpenter
0 siblings, 1 reply; 6+ messages in thread
From: Eric Biggers @ 2025-04-30 16:50 UTC (permalink / raw)
To: Dan Carpenter
Cc: Satya Tangirala, Alasdair Kergon, Mike Snitzer, Mikulas Patocka,
dm-devel, linux-kernel, kernel-janitors
On Wed, Apr 30, 2025 at 11:05:54AM +0300, Dan Carpenter wrote:
> We need to call dm_put_live_table() even if dm_get_live_table() returns
> NULL.
>
> Fixes: 9355a9eb21a5 ("dm: support key eviction from keyslot managers of underlying devices")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> drivers/md/dm-table.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
Reviewed-by: Eric Biggers <ebiggers@kernel.org>
But that's an awfully error-prone API.
dm_blk_report_zones() gets this wrong too.
- Eric
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] dm: add missing unlock on in dm_keyslot_evict()
2025-04-30 16:50 ` Eric Biggers
@ 2025-04-30 17:40 ` Dan Carpenter
2025-04-30 19:17 ` Mikulas Patocka
0 siblings, 1 reply; 6+ messages in thread
From: Dan Carpenter @ 2025-04-30 17:40 UTC (permalink / raw)
To: Eric Biggers
Cc: Satya Tangirala, Alasdair Kergon, Mike Snitzer, Mikulas Patocka,
dm-devel, linux-kernel, kernel-janitors
On Wed, Apr 30, 2025 at 09:50:37AM -0700, Eric Biggers wrote:
> On Wed, Apr 30, 2025 at 11:05:54AM +0300, Dan Carpenter wrote:
> > We need to call dm_put_live_table() even if dm_get_live_table() returns
> > NULL.
> >
> > Fixes: 9355a9eb21a5 ("dm: support key eviction from keyslot managers of underlying devices")
> > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> > ---
> > drivers/md/dm-table.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
>
> Reviewed-by: Eric Biggers <ebiggers@kernel.org>
>
> But that's an awfully error-prone API.
Yep.
>
> dm_blk_report_zones() gets this wrong too.
Ugh... dm_blk_report_zones() is too weird for my static checker tool.
The checker is looking very specifically for error paths with missing
unlocks.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] dm: add missing unlock on in dm_keyslot_evict()
2025-04-30 17:40 ` Dan Carpenter
@ 2025-04-30 19:17 ` Mikulas Patocka
2025-05-04 11:30 ` Mikulas Patocka
0 siblings, 1 reply; 6+ messages in thread
From: Mikulas Patocka @ 2025-04-30 19:17 UTC (permalink / raw)
To: Dan Carpenter, Benjamin Marzinski
Cc: Eric Biggers, Satya Tangirala, Alasdair Kergon, Mike Snitzer,
dm-devel, linux-kernel, kernel-janitors
On Wed, 30 Apr 2025, Dan Carpenter wrote:
> On Wed, Apr 30, 2025 at 09:50:37AM -0700, Eric Biggers wrote:
> > On Wed, Apr 30, 2025 at 11:05:54AM +0300, Dan Carpenter wrote:
> > > We need to call dm_put_live_table() even if dm_get_live_table() returns
> > > NULL.
> > >
> > > Fixes: 9355a9eb21a5 ("dm: support key eviction from keyslot managers of underlying devices")
> > > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> > > ---
> > > drivers/md/dm-table.c | 3 ++-
> > > 1 file changed, 2 insertions(+), 1 deletion(-)
> > >
> >
> > Reviewed-by: Eric Biggers <ebiggers@kernel.org>
> >
> > But that's an awfully error-prone API.
>
> Yep.
>
> >
> > dm_blk_report_zones() gets this wrong too.
>
> Ugh... dm_blk_report_zones() is too weird for my static checker tool.
> The checker is looking very specifically for error paths with missing
> unlocks.
Ben already tried to fix it in dm_blk_report_zones (see the linux-dm git,
for-next branch) - but his fix is incorrect because the "if" condition for
dm_get_live_table and dm_put_live_table differs. I'll update his patch to
fix this mismatch.
Mikulas
> regards,
> dan carpenter
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] dm: add missing unlock on in dm_keyslot_evict()
2025-04-30 19:17 ` Mikulas Patocka
@ 2025-05-04 11:30 ` Mikulas Patocka
2025-05-05 14:51 ` Benjamin Marzinski
0 siblings, 1 reply; 6+ messages in thread
From: Mikulas Patocka @ 2025-05-04 11:30 UTC (permalink / raw)
To: Benjamin Marzinski, Dan Carpenter
Cc: Eric Biggers, Satya Tangirala, Alasdair Kergon, Mike Snitzer,
dm-devel, linux-kernel, kernel-janitors
On Wed, 30 Apr 2025, Mikulas Patocka wrote:
> Ben already tried to fix it in dm_blk_report_zones (see the linux-dm git,
> for-next branch) - but his fix is incorrect because the "if" condition for
> dm_get_live_table and dm_put_live_table differs. I'll update his patch to
> fix this mismatch.
>
> Mikulas
I fixed it in the Ben's patch "dm: fix dm_blk_report_zones". Ben, please
review it - it's the patch 37f53a2c60d03743e0eacf7a0c01c279776fef4e in the
linux-dm repository, for-next branch.
Mikulas
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] dm: add missing unlock on in dm_keyslot_evict()
2025-05-04 11:30 ` Mikulas Patocka
@ 2025-05-05 14:51 ` Benjamin Marzinski
0 siblings, 0 replies; 6+ messages in thread
From: Benjamin Marzinski @ 2025-05-05 14:51 UTC (permalink / raw)
To: Mikulas Patocka
Cc: Dan Carpenter, Eric Biggers, Satya Tangirala, Alasdair Kergon,
Mike Snitzer, dm-devel, linux-kernel, kernel-janitors
On Sun, May 04, 2025 at 01:30:42PM +0200, Mikulas Patocka wrote:
>
>
> On Wed, 30 Apr 2025, Mikulas Patocka wrote:
>
> > Ben already tried to fix it in dm_blk_report_zones (see the linux-dm git,
> > for-next branch) - but his fix is incorrect because the "if" condition for
> > dm_get_live_table and dm_put_live_table differs. I'll update his patch to
> > fix this mismatch.
> >
> > Mikulas
>
> I fixed it in the Ben's patch "dm: fix dm_blk_report_zones". Ben, please
> review it - it's the patch 37f53a2c60d03743e0eacf7a0c01c279776fef4e in the
> linux-dm repository, for-next branch.
Your changes look good. Thanks for catching that.
-Ben
>
> Mikulas
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-05-05 14:51 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-30 8:05 [PATCH] dm: add missing unlock on in dm_keyslot_evict() Dan Carpenter
2025-04-30 16:50 ` Eric Biggers
2025-04-30 17:40 ` Dan Carpenter
2025-04-30 19:17 ` Mikulas Patocka
2025-05-04 11:30 ` Mikulas Patocka
2025-05-05 14:51 ` Benjamin Marzinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox