Re: md: dm-table: ensure dev_t is initialized

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jan 31 2023 at  6:15P -0500,
Tomas Melin <tomas.melin@xxxxxxxxxxx> wrote:

> Avoid returning uninitialized value in case
> lookup fails.
> 
> Signed-off-by: Tomas Melin <tomas.melin@xxxxxxxxxxx>
> ---
>  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@xxxxxxxxxx>

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux