Message ID | 20230131111552.24349-1-tomas.melin@vaisala.com (mailing list archive) |
---|---|
State | Rejected, archived |
Delegated to: | Mike Snitzer |
Headers | show |
Series | md: dm-table: ensure dev_t is initialized | expand |
On Tue, Jan 31 2023 at 6:15P -0500, Tomas Melin <tomas.melin@vaisala.com> wrote: > Avoid returning uninitialized value in case > lookup fails. > > Signed-off-by: Tomas Melin <tomas.melin@vaisala.com> > --- > drivers/md/dm-table.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c > index 8fc44c9f746a..71c59455bf3b 100644 > --- a/drivers/md/dm-table.c > +++ b/drivers/md/dm-table.c > @@ -331,7 +331,7 @@ static int upgrade_mode(struct dm_dev_internal *dd, fmode_t new_mode, > */ > dev_t dm_get_dev_t(const char *path) > { > - dev_t dev; > + dev_t dev = 0; > > if (lookup_bdev(path, &dev)) > dev = name_to_dev_t(path); dev_t dm_get_dev_t(const char *path) { dev_t dev; if (lookup_bdev(path, &dev)) dev = name_to_dev_t(path); return dev; } If lookup fails then: dev = name_to_dev_t(path); name_to_dev_t() will initialize dev no matter what. Nacked-by: Mike Snitzer <snitzer@kernel.org> -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 8fc44c9f746a..71c59455bf3b 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -331,7 +331,7 @@ static int upgrade_mode(struct dm_dev_internal *dd, fmode_t new_mode, */ dev_t dm_get_dev_t(const char *path) { - dev_t dev; + dev_t dev = 0; if (lookup_bdev(path, &dev)) dev = name_to_dev_t(path);
Avoid returning uninitialized value in case lookup fails. Signed-off-by: Tomas Melin <tomas.melin@vaisala.com> --- drivers/md/dm-table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)