Skip to contentSkip to conversation

nvme: initialize variable before logical OR'ing it

PATCH New Jay Freyensee 3 participants 5 messages Jun 2, 2016 – Jul 21, 2016 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme: initialize variable before logical OR'ing it

It is typically not good coding or secure coding practice to logical OR a variable without an initialization value first. Here on this line:

integrity.flags |= BLK_INTEGRITY_DEVICE_CAPABLE;

BLK_INTEGRITY_DEVICE_CAPABLE is being OR'ed to a member variable never set to an initial value. This patch fixes that.

Signed-off-by Jay Freyensee <james.p.freyensee at intel.com>
Reviewed-by Ming Lin <ming.l at samsung.com>
Reviewed-by Sagi Grimberg <sagi at grimberg.me>
Reviewed-by Christoph Hellwig <hch at lst.de>
---
 drivers/nvme/host/core.c | 1 +
 1 file changed, 1 insertion(+)
drivers/nvme/host/core.c +1 -0
index f6f6fdf..33fe610 100644
@@ -843,6 +843,7 @@ static void nvme_init_integrity(struct nvme_ns *ns)
 {
 	struct blk_integrity integrity;
 
+	memset(&integrity, 0, sizeof(integrity));
 	switch (ns->pi_type) {
 	case NVME_NS_DPS_PI_TYPE3:
 		integrity.profile = &t10_pi_type3_crc;
Signature · 1 line
2.4.3
#1 lore raw

PATCH 1/1 nvme: initialize variable before logical OR'ing it

On Thu, 2016-06-02@08:51 -0700, Jay Freyensee wrote:

Ping?

Quoted 31 lines

It is typically not good coding or secure coding practice to logical OR a variable without an initialization value first. Here on this line:

integrity.flags |= BLK_INTEGRITY_DEVICE_CAPABLE;

BLK_INTEGRITY_DEVICE_CAPABLE is being OR'ed to a member variable never set to an initial value. This patch fixes that.

Signed-off-by Jay Freyensee <james.p.freyensee at intel.com>
Reviewed-by Ming Lin <ming.l at samsung.com>
Reviewed-by Sagi Grimberg <sagi at grimberg.me>
Reviewed-by Christoph Hellwig <hch at lst.de>
---
 drivers/nvme/host/core.c | 1 +
 1 file changed, 1 insertion(+)
drivers/nvme/host/core.c +1 -0
index f6f6fdf..33fe610 100644
@@ -843,6 +843,7 @@ static void nvme_init_integrity(struct nvme_ns
 *ns)
 {
 	struct blk_integrity integrity;
 
+	memset(&integrity, 0, sizeof(integrity));
 	switch (ns->pi_type) {
 	case NVME_NS_DPS_PI_TYPE3:

integrity.profile = &t10_pi_type3_crc;

#2 lore raw

PATCH 1/1 nvme: initialize variable before logical OR'ing it

In reply to Jay Freyensee

On Thu, 2016-06-02@08:51 -0700, Jay Freyensee wrote:

Jens,

I believe this patch fix got missed? Or is there a problem with this patch?

Thanks,
Jay

Quoted 31 lines

It is typically not good coding or secure coding practice to logical OR a variable without an initialization value first. Here on this line:

integrity.flags |= BLK_INTEGRITY_DEVICE_CAPABLE;

BLK_INTEGRITY_DEVICE_CAPABLE is being OR'ed to a member variable never set to an initial value. This patch fixes that.

Signed-off-by Jay Freyensee <james.p.freyensee at intel.com>
Reviewed-by Ming Lin <ming.l at samsung.com>
Reviewed-by Sagi Grimberg <sagi at grimberg.me>
Reviewed-by Christoph Hellwig <hch at lst.de>
---
 drivers/nvme/host/core.c | 1 +
 1 file changed, 1 insertion(+)
drivers/nvme/host/core.c +1 -0
index f6f6fdf..33fe610 100644
@@ -843,6 +843,7 @@ static void nvme_init_integrity(struct nvme_ns
 *ns)
 {
 	struct blk_integrity integrity;
 
+	memset(&integrity, 0, sizeof(integrity));
 	switch (ns->pi_type) {
 	case NVME_NS_DPS_PI_TYPE3:

integrity.profile = &t10_pi_type3_crc;

maintainer
#3 lore raw

PATCH 1/1 nvme: initialize variable before logical OR'ing it

Quoted 6 lines · J Freyensee

On Thu, 2016-06-02@08:51 -0700, Jay Freyensee wrote:

Jens,

I believe this patch fix got missed? Or is there a problem with this patch?

No problem, just got missed. Added, thanks.

Signature · 1 line
Jens Axboe
#4 lore raw

PATCH 1/1 nvme: initialize variable before logical OR'ing it

Quoted 11 lines · Jens Axboe
Quoted 7 lines · J Freyensee

On Thu, 2016-06-02@08:51 -0700, Jay Freyensee wrote:

Jens,

I believe this patch fix got missed? Or is there a problem with this
patch?

No problem, just got missed. Added, thanks.

Thanks Jens!

Quoted 1 line