[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK8P3a2pSRu0OKDNrNJSdviRgcv8Lw1mwZr5opv=UbtHLps2oQ@mail.gmail.com>
Date: Mon, 12 Apr 2021 20:41:38 +0200
From: Arnd Bergmann <arnd@...db.de>
To: Colin King <colin.king@...onical.com>
Cc: Oded Gabbay <ogabbay@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Ofir Bitton <obitton@...ana.ai>,
kernel-janitors@...r.kernel.org,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH][next] habanalabs/gaudi: Fix uninitialized return code rc
when read size is zero
On Mon, Apr 12, 2021 at 6:11 PM Colin King <colin.king@...onical.com> wrote:
>
> From: Colin Ian King <colin.king@...onical.com>
>
> In the case where size is zero the while loop never assigns rc and the
> return value is uninitialized. Fix this by initializing rc to zero.
>
> Addresses-Coverity: ("Uninitialized scalar variable")
> Fixes: 639781dcab82 ("habanalabs/gaudi: add debugfs to DMA from the device")
> Signed-off-by: Colin Ian King <colin.king@...onical.com>
> ---
> drivers/misc/habanalabs/gaudi/gaudi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/misc/habanalabs/gaudi/gaudi.c b/drivers/misc/habanalabs/gaudi/gaudi.c
> index 8730b691ec61..b751652f80a8 100644
> --- a/drivers/misc/habanalabs/gaudi/gaudi.c
> +++ b/drivers/misc/habanalabs/gaudi/gaudi.c
> @@ -6252,7 +6252,7 @@ static int gaudi_debugfs_read_dma(struct hl_device *hdev, u64 addr, u32 size,
> dma_addr_t dma_addr;
> void *kernel_addr;
> bool is_eng_idle;
> - int rc, dma_id;
> + int rc = 0, dma_id;
>
> kernel_addr = hdev->asic_funcs->asic_dma_alloc_coherent(
> hdev, SZ_2M,
In general, I don't like adding initializations during the declaration as that
tends to hide warnings for the cases where a later initialization is
missing. In this case it looks correct though.
Acked-by: Arnd Bergmann <arnd@...db.de>
Powered by blists - more mailing lists