lkml.org 
[lkml]   [2020]   [Feb]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] nvme: fix uninitialized-variable warning
On Thu, Jan 30, 2020 at 07:48:15AM -0800, Christoph Hellwig wrote:
> On Thu, Jan 30, 2020 at 04:36:48PM +0100, Arnd Bergmann wrote:
> > > This one is just gross. I think we'll need to find some other fix
> > > that doesn't obsfucate the code as much.
> >
> > Initializing the nvme_result in nvme_features() would do it, as would
> > setting it in the error path in __nvme_submit_sync_cmd() -- either
> > way the compiler cannot be confused about whether it is initialized
> > later on.
>
> Given that this is outside the hot path we can just zero the whole
> structure before submitting the I/O.

I think this should be okay:

---
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 7f05deada7f4..4aeed750dab2 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1165,8 +1165,8 @@ static int nvme_identify_ns(struct nvme_ctrl *ctrl,
static int nvme_features(struct nvme_ctrl *dev, u8 op, unsigned int fid,
unsigned int dword11, void *buffer, size_t buflen, u32 *result)
{
+ union nvme_result res = { 0 };
struct nvme_command c;
- union nvme_result res;
int ret;

memset(&c, 0, sizeof(c));
--
\
 
 \ /
  Last update: 2020-02-13 20:51    [W:0.051 / U:0.476 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site