Skip to contentSkip to conversation

libnvdimm, nfit, nd_blk: driver for BLK-mode access persistent memory

DISCUSSION Dan Carpenter 2 participants 2 messages Jun 30, 2015 ACPI

lore
Share & tools
lore
#0 lore raw

Hello Ross Zwisler,

This is a semi-automatic email about new static checker warnings.

The patch 047fc8a1f9a6: "libnvdimm, nfit, nd_blk: driver for BLK-mode access persistent memory" from Jun 25, 2015, leads to the following Smatch complaint:

drivers/acpi/nfit.c:1224 acpi_nfit_blk_region_enable()
error: we previously assumed 'nfit_mem' could be null (see line 1223)

drivers/acpi/nfit.c
1222 nfit_mem = nvdimm_provider_data(nvdimm);

  1223		if (!nfit_mem || !nfit_mem->dcr || !nfit_mem->bdw) {
                     ^^^^^^^^

Check.

1224 dev_dbg(dev, "%s: missing%s%s%s\n", __func__,
1225 nfit_mem ? "" : " nfit_mem",
1226 nfit_mem->dcr ? "" : " dcr",

                                        ^^^^^^^^^^^^^

Unchecked dereference.

regards,
dan carpenter

Acked-by Ross Zwisler
#1 lore raw
Quoted 15 lines · Dan Carpenter

Hello Ross Zwisler,

This is a semi-automatic email about new static checker warnings.

The patch 047fc8a1f9a6: "libnvdimm, nfit, nd_blk: driver for BLK-mode access persistent memory" from Jun 25, 2015, leads to the following Smatch complaint:

drivers/acpi/nfit.c:1224 acpi_nfit_blk_region_enable()
error: we previously assumed 'nfit_mem' could be null (see line 1223)

drivers/acpi/nfit.c
1222 nfit_mem = nvdimm_provider_data(nvdimm);

  1223		if (!nfit_mem || !nfit_mem->dcr || !nfit_mem->bdw) {
                     ^^^^^^^^
Quoted 7 lines

Check.

1224 dev_dbg(dev, "%s: missing%s%s%s\n", __func__,
1225 nfit_mem ? "" : " nfit_mem",
1226 nfit_mem->dcr ? "" : " dcr",

                                        ^^^^^^^^^^^^^

Unchecked dereference.

Thanks Dan!

8<-----
nfit: fix smatch "use after null check" report

From: Dan Williams <[email protected]>

drivers/acpi/nfit.c:1224 acpi_nfit_blk_region_enable()
error: we previously assumed 'nfit_mem' could be null (see line 1223)

drivers/acpi/nfit.c
1222 nfit_mem = nvdimm_provider_data(nvdimm);

  1223          if (!nfit_mem || !nfit_mem->dcr || !nfit_mem->bdw) {
                     ^^^^^^^^

Check.

1224 dev_dbg(dev, "%s: missing%s%s%s\n", __func__,
1225 nfit_mem ? "" : " nfit_mem",
1226 nfit_mem->dcr ? "" : " dcr",

                                        ^^^^^^^^^^^^^

Unchecked dereference.

---
 drivers/acpi/nfit.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/nfit.c +2 -2
index 2161fa178c8d..a20b7c883ca0 100644
@@ -1223,8 +1223,8 @@ static int acpi_nfit_blk_region_enable(struct nvdimm_bus *nvdimm_bus,
 	if (!nfit_mem || !nfit_mem->dcr || !nfit_mem->bdw) {
 		dev_dbg(dev, "%s: missing%s%s%s\n", __func__,
 				nfit_mem ? "" : " nfit_mem",
-				nfit_mem->dcr ? "" : " dcr",
-				nfit_mem->bdw ? "" : " bdw");
+				(nfit_mem && nfit_mem->dcr) ? "" : " dcr",
+				(nfit_mem && nfit_mem->bdw) ? "" : " bdw");
 		return -ENXIO;
 	}