* [PATCH][next] dm space maps: Fix uninitialized variable r2
@ 2021-05-21 9:40 Colin King
2021-05-21 9:47 ` NAK: " Colin Ian King
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2021-05-21 9:40 UTC (permalink / raw)
To: Alasdair Kergon, Mike Snitzer, dm-devel, Joe Thornber
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
In the case where recursing(mm) is true variable r2 is not
inintialized and an uninitialized value is being used in the
call combine_errors later on. Fix this by setting r2 to zero.
Addresses-Coverity: ("Uninitialized scalar variable")
Fixes: def6a7a9a7f0 ("dm space maps: improve performance with inc/dec on ranges of blocks")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/md/persistent-data/dm-space-map-metadata.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/md/persistent-data/dm-space-map-metadata.c b/drivers/md/persistent-data/dm-space-map-metadata.c
index 3b70ee861cf5..5be5ef4c831f 100644
--- a/drivers/md/persistent-data/dm-space-map-metadata.c
+++ b/drivers/md/persistent-data/dm-space-map-metadata.c
@@ -432,9 +432,10 @@ static int sm_metadata_dec_blocks(struct dm_space_map *sm, dm_block_t b, dm_bloc
int32_t nr_allocations;
struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
- if (recursing(smm))
+ if (recursing(smm)) {
r = add_bop(smm, BOP_DEC, b, e);
- else {
+ r2 = 0;
+ } else {
in(smm);
r = sm_ll_dec(&smm->ll, b, e, &nr_allocations);
r2 = out(smm);
--
2.31.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* NAK: [PATCH][next] dm space maps: Fix uninitialized variable r2
2021-05-21 9:40 [PATCH][next] dm space maps: Fix uninitialized variable r2 Colin King
@ 2021-05-21 9:47 ` Colin Ian King
0 siblings, 0 replies; 2+ messages in thread
From: Colin Ian King @ 2021-05-21 9:47 UTC (permalink / raw)
To: Alasdair Kergon, Mike Snitzer, dm-devel, Joe Thornber
Cc: kernel-janitors, linux-kernel
On 21/05/2021 10:40, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> In the case where recursing(mm) is true variable r2 is not
> inintialized and an uninitialized value is being used in the
> call combine_errors later on. Fix this by setting r2 to zero.
>
> Addresses-Coverity: ("Uninitialized scalar variable")
> Fixes: def6a7a9a7f0 ("dm space maps: improve performance with inc/dec on ranges of blocks")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/md/persistent-data/dm-space-map-metadata.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/md/persistent-data/dm-space-map-metadata.c b/drivers/md/persistent-data/dm-space-map-metadata.c
> index 3b70ee861cf5..5be5ef4c831f 100644
> --- a/drivers/md/persistent-data/dm-space-map-metadata.c
> +++ b/drivers/md/persistent-data/dm-space-map-metadata.c
> @@ -432,9 +432,10 @@ static int sm_metadata_dec_blocks(struct dm_space_map *sm, dm_block_t b, dm_bloc
> int32_t nr_allocations;
> struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
>
> - if (recursing(smm))
> + if (recursing(smm)) {
> r = add_bop(smm, BOP_DEC, b, e);
> - else {
> + r2 = 0;
> + } else {
> in(smm);
> r = sm_ll_dec(&smm->ll, b, e, &nr_allocations);
> r2 = out(smm);
>
There is a another occurrence of this, I'll send a V2 shortly
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-05-21 9:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-21 9:40 [PATCH][next] dm space maps: Fix uninitialized variable r2 Colin King
2021-05-21 9:47 ` NAK: " Colin Ian King
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).