2022-03-08 23:57:57

by Nava kishore Manne

[permalink] [raw]
Subject: [PATCH 2/6] fpga: zynqmp: Initialized variables before using it

This patch initialized variables with the proper value.
Addresses-Coverity: "uninit_use: Using uninitialized value"

Signed-off-by: Nava kishore Manne <[email protected]>
---
drivers/fpga/zynqmp-fpga.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/fpga/zynqmp-fpga.c b/drivers/fpga/zynqmp-fpga.c
index c60f20949c47..e931d69819a7 100644
--- a/drivers/fpga/zynqmp-fpga.c
+++ b/drivers/fpga/zynqmp-fpga.c
@@ -41,7 +41,7 @@ static int zynqmp_fpga_ops_write(struct fpga_manager *mgr,
const char *buf, size_t size)
{
struct zynqmp_fpga_priv *priv;
- dma_addr_t dma_addr;
+ dma_addr_t dma_addr = 0;
u32 eemi_flags = 0;
char *kbuf;
int ret;
--
2.25.1


2022-03-11 23:28:49

by Xu Yilun

[permalink] [raw]
Subject: Re: [PATCH 2/6] fpga: zynqmp: Initialized variables before using it

On Tue, Mar 08, 2022 at 03:15:15PM +0530, Nava kishore Manne wrote:
> This patch initialized variables with the proper value.
> Addresses-Coverity: "uninit_use: Using uninitialized value"
>
> Signed-off-by: Nava kishore Manne <[email protected]>
> ---
> drivers/fpga/zynqmp-fpga.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/fpga/zynqmp-fpga.c b/drivers/fpga/zynqmp-fpga.c
> index c60f20949c47..e931d69819a7 100644
> --- a/drivers/fpga/zynqmp-fpga.c
> +++ b/drivers/fpga/zynqmp-fpga.c
> @@ -41,7 +41,7 @@ static int zynqmp_fpga_ops_write(struct fpga_manager *mgr,
> const char *buf, size_t size)
> {
> struct zynqmp_fpga_priv *priv;
> - dma_addr_t dma_addr;
> + dma_addr_t dma_addr = 0;

The first use of this variable is as an output parameter:

kbuf = dma_alloc_coherent(priv->dev, size, &dma_addr, GFP_KERNEL);

So I don't think it needs to be initialized as 0.

Thanks,
Yilun

> u32 eemi_flags = 0;
> char *kbuf;
> int ret;
> --
> 2.25.1

2022-03-17 05:58:37

by Xu Yilun

[permalink] [raw]
Subject: Re: [PATCH 2/6] fpga: zynqmp: Initialized variables before using it

On Tue, Mar 15, 2022 at 11:48:11AM +0000, Nava kishore Manne wrote:
> Hi Yilun,
>
> Thanks for providing the review comments.
> Please find my response inline.
>
> > -----Original Message-----
> > From: Xu Yilun <[email protected]>
> > Sent: Friday, March 11, 2022 7:58 PM
> > To: Nava kishore Manne <[email protected]>
> > Cc: [email protected]; [email protected]; [email protected]; Michal Simek
> > <[email protected]>; [email protected]; linux-
> > [email protected]; [email protected]
> > Subject: Re: [PATCH 2/6] fpga: zynqmp: Initialized variables before using it
> >
> > On Tue, Mar 08, 2022 at 03:15:15PM +0530, Nava kishore Manne wrote:
> > > This patch initialized variables with the proper value.
> > > Addresses-Coverity: "uninit_use: Using uninitialized value"
> > >
> > > Signed-off-by: Nava kishore Manne <[email protected]>
> > > ---
> > > drivers/fpga/zynqmp-fpga.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/fpga/zynqmp-fpga.c b/drivers/fpga/zynqmp-fpga.c
> > > index c60f20949c47..e931d69819a7 100644
> > > --- a/drivers/fpga/zynqmp-fpga.c
> > > +++ b/drivers/fpga/zynqmp-fpga.c
> > > @@ -41,7 +41,7 @@ static int zynqmp_fpga_ops_write(struct
> > fpga_manager *mgr,
> > > const char *buf, size_t size)
> > > {
> > > struct zynqmp_fpga_priv *priv;
> > > - dma_addr_t dma_addr;
> > > + dma_addr_t dma_addr = 0;
> >
> > The first use of this variable is as an output parameter:
> >
> > kbuf = dma_alloc_coherent(priv->dev, size, &dma_addr,
> > GFP_KERNEL);
> >
> > So I don't think it needs to be initialized as 0.
> >
>
> This issue is found by Coverity Scan, Whether this param is input/output this fix will not impact the actual functionality.
> In order to fix the issues reported by the Coverity tool, this fix is needed.

I didn't see issues about this piece of code, so I don't think we need
the fix just to make the tool happy. Maybe the tool could be improved to
help us better.

Thanks,
Yilun

>
> Regards,
> Navakishore.

2022-03-17 06:39:52

by Nava kishore Manne

[permalink] [raw]
Subject: RE: [PATCH 2/6] fpga: zynqmp: Initialized variables before using it

Hi Yilun,

Thanks for providing the review comments.
Please find my response inline.

> -----Original Message-----
> From: Xu Yilun <[email protected]>
> Sent: Friday, March 11, 2022 7:58 PM
> To: Nava kishore Manne <[email protected]>
> Cc: [email protected]; [email protected]; [email protected]; Michal Simek
> <[email protected]>; [email protected]; linux-
> [email protected]; [email protected]
> Subject: Re: [PATCH 2/6] fpga: zynqmp: Initialized variables before using it
>
> On Tue, Mar 08, 2022 at 03:15:15PM +0530, Nava kishore Manne wrote:
> > This patch initialized variables with the proper value.
> > Addresses-Coverity: "uninit_use: Using uninitialized value"
> >
> > Signed-off-by: Nava kishore Manne <[email protected]>
> > ---
> > drivers/fpga/zynqmp-fpga.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/fpga/zynqmp-fpga.c b/drivers/fpga/zynqmp-fpga.c
> > index c60f20949c47..e931d69819a7 100644
> > --- a/drivers/fpga/zynqmp-fpga.c
> > +++ b/drivers/fpga/zynqmp-fpga.c
> > @@ -41,7 +41,7 @@ static int zynqmp_fpga_ops_write(struct
> fpga_manager *mgr,
> > const char *buf, size_t size)
> > {
> > struct zynqmp_fpga_priv *priv;
> > - dma_addr_t dma_addr;
> > + dma_addr_t dma_addr = 0;
>
> The first use of this variable is as an output parameter:
>
> kbuf = dma_alloc_coherent(priv->dev, size, &dma_addr,
> GFP_KERNEL);
>
> So I don't think it needs to be initialized as 0.
>

This issue is found by Coverity Scan, Whether this param is input/output this fix will not impact the actual functionality.
In order to fix the issues reported by the Coverity tool, this fix is needed.

Regards,
Navakishore.

2022-03-22 07:23:52

by Nava kishore Manne

[permalink] [raw]
Subject: RE: [PATCH 2/6] fpga: zynqmp: Initialized variables before using it

Hi Yilun,

Please find my response inline.

> -----Original Message-----
> From: Xu Yilun <[email protected]>
> Sent: Tuesday, March 15, 2022 9:39 PM
> To: Nava kishore Manne <[email protected]>
> Cc: [email protected]; [email protected]; [email protected]; Michal Simek
> <[email protected]>; [email protected]; linux-
> [email protected]; [email protected]
> Subject: Re: [PATCH 2/6] fpga: zynqmp: Initialized variables before using it
>
> On Tue, Mar 15, 2022 at 11:48:11AM +0000, Nava kishore Manne wrote:
> > Hi Yilun,
> >
> > Thanks for providing the review comments.
> > Please find my response inline.
> >
> > > -----Original Message-----
> > > From: Xu Yilun <[email protected]>
> > > Sent: Friday, March 11, 2022 7:58 PM
> > > To: Nava kishore Manne <[email protected]>
> > > Cc: [email protected]; [email protected]; [email protected]; Michal Simek
> > > <[email protected]>; [email protected]; linux-
> > > [email protected]; [email protected]
> > > Subject: Re: [PATCH 2/6] fpga: zynqmp: Initialized variables before
> > > using it
> > >
> > > On Tue, Mar 08, 2022 at 03:15:15PM +0530, Nava kishore Manne wrote:
> > > > This patch initialized variables with the proper value.
> > > > Addresses-Coverity: "uninit_use: Using uninitialized value"
> > > >
> > > > Signed-off-by: Nava kishore Manne <[email protected]>
> > > > ---
> > > > drivers/fpga/zynqmp-fpga.c | 2 +-
> > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/fpga/zynqmp-fpga.c
> > > > b/drivers/fpga/zynqmp-fpga.c index c60f20949c47..e931d69819a7
> > > > 100644
> > > > --- a/drivers/fpga/zynqmp-fpga.c
> > > > +++ b/drivers/fpga/zynqmp-fpga.c
> > > > @@ -41,7 +41,7 @@ static int zynqmp_fpga_ops_write(struct
> > > fpga_manager *mgr,
> > > > const char *buf, size_t size) {
> > > > struct zynqmp_fpga_priv *priv;
> > > > - dma_addr_t dma_addr;
> > > > + dma_addr_t dma_addr = 0;
> > >
> > > The first use of this variable is as an output parameter:
> > >
> > > kbuf = dma_alloc_coherent(priv->dev, size, &dma_addr,
> GFP_KERNEL);
> > >
> > > So I don't think it needs to be initialized as 0.
> > >
> >
> > This issue is found by Coverity Scan, Whether this param is input/output
> this fix will not impact the actual functionality.
> > In order to fix the issues reported by the Coverity tool, this fix is needed.
>
> I didn't see issues about this piece of code, so I don't think we need the fix
> just to make the tool happy. Maybe the tool could be improved to help us
> better.
>

Agreed, I will drop this patch in v2.

Regards,
Navakishore.