* [PATCH][next] habanalabs/gaudi: Fix uninitialized return code rc when read size is zero
@ 2021-04-12 16:10 Colin King
2021-04-12 18:41 ` Arnd Bergmann
0 siblings, 1 reply; 4+ messages in thread
From: Colin King @ 2021-04-12 16:10 UTC (permalink / raw)
To: Oded Gabbay, Arnd Bergmann, Greg Kroah-Hartman, Ofir Bitton
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.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@canonical.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,
--
2.30.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH][next] habanalabs/gaudi: Fix uninitialized return code rc when read size is zero
2021-04-12 16:10 [PATCH][next] habanalabs/gaudi: Fix uninitialized return code rc when read size is zero Colin King
@ 2021-04-12 18:41 ` Arnd Bergmann
2021-04-15 7:08 ` Oded Gabbay
0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2021-04-12 18:41 UTC (permalink / raw)
To: Colin King
Cc: Oded Gabbay, Greg Kroah-Hartman, Ofir Bitton, kernel-janitors,
Linux Kernel Mailing List
On Mon, Apr 12, 2021 at 6:11 PM Colin King <colin.king@canonical.com> wrote:
>
> From: Colin Ian King <colin.king@canonical.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@canonical.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@arndb.de>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][next] habanalabs/gaudi: Fix uninitialized return code rc when read size is zero
2021-04-12 18:41 ` Arnd Bergmann
@ 2021-04-15 7:08 ` Oded Gabbay
2021-04-15 7:19 ` Greg Kroah-Hartman
0 siblings, 1 reply; 4+ messages in thread
From: Oded Gabbay @ 2021-04-15 7:08 UTC (permalink / raw)
To: Arnd Bergmann, Greg Kroah-Hartman, Colin King
Cc: Oded Gabbay, Ofir Bitton, kernel-janitors, Linux Kernel Mailing List
On Mon, Apr 12, 2021 at 9:41 PM Arnd Bergmann <arnd@arndb.de> wrote:
>
> On Mon, Apr 12, 2021 at 6:11 PM Colin King <colin.king@canonical.com> wrote:
> >
> > From: Colin Ian King <colin.king@canonical.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@canonical.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@arndb.de>
I don't mind taking this patch for eliminating the warning but fyi,
the caller function (hl_dma_size_write) checks that the size is not
zero. If the size is zero, we never reach this function.
Greg, do you mind applying it directly to your -next branch ? I don't
have anything pending and I'm too lazy sending a pull request on a
single patch ;)
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Thanks,
Oded
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][next] habanalabs/gaudi: Fix uninitialized return code rc when read size is zero
2021-04-15 7:08 ` Oded Gabbay
@ 2021-04-15 7:19 ` Greg Kroah-Hartman
0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2021-04-15 7:19 UTC (permalink / raw)
To: Oded Gabbay
Cc: Arnd Bergmann, Colin King, Oded Gabbay, Ofir Bitton,
kernel-janitors, Linux Kernel Mailing List
On Thu, Apr 15, 2021 at 10:08:26AM +0300, Oded Gabbay wrote:
> On Mon, Apr 12, 2021 at 9:41 PM Arnd Bergmann <arnd@arndb.de> wrote:
> >
> > On Mon, Apr 12, 2021 at 6:11 PM Colin King <colin.king@canonical.com> wrote:
> > >
> > > From: Colin Ian King <colin.king@canonical.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@canonical.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@arndb.de>
>
> I don't mind taking this patch for eliminating the warning but fyi,
> the caller function (hl_dma_size_write) checks that the size is not
> zero. If the size is zero, we never reach this function.
>
> Greg, do you mind applying it directly to your -next branch ? I don't
> have anything pending and I'm too lazy sending a pull request on a
> single patch ;)
>
> Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
I can grab it from this thread, thanks!
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-04-15 7:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-12 16:10 [PATCH][next] habanalabs/gaudi: Fix uninitialized return code rc when read size is zero Colin King
2021-04-12 18:41 ` Arnd Bergmann
2021-04-15 7:08 ` Oded Gabbay
2021-04-15 7:19 ` Greg Kroah-Hartman
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).