Skip to content

Commit 91bf79b

Browse files
committed
Merge branch 'for-5.6/libnvdimm-fixes' into libnvdimm-for-next
Pick up some miscellaneous minor fixes, that missed v5.6-final, including a some smatch reports in the ioctl path and some unit test compilation fixups.
2 parents 04ff486 + 1f77679 commit 91bf79b

File tree

7 files changed

+18
-10
lines changed

7 files changed

+18
-10
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9569,6 +9569,7 @@ F: drivers/acpi/nfit/*
95699569
F: include/linux/nd.h
95709570
F: include/linux/libnvdimm.h
95719571
F: include/uapi/linux/ndctl.h
9572+
F: tools/testing/nvdimm/
95729573

95739574
LICENSES and SPDX stuff
95749575
M: Thomas Gleixner <[email protected]>

drivers/acpi/nfit/core.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ static union acpi_object *acpi_label_info(acpi_handle handle)
360360

361361
static u8 nfit_dsm_revid(unsigned family, unsigned func)
362362
{
363-
static const u8 revid_table[NVDIMM_FAMILY_MAX+1][32] = {
363+
static const u8 revid_table[NVDIMM_FAMILY_MAX+1][NVDIMM_CMD_MAX+1] = {
364364
[NVDIMM_FAMILY_INTEL] = {
365365
[NVDIMM_INTEL_GET_MODES] = 2,
366366
[NVDIMM_INTEL_GET_FWINFO] = 2,
@@ -386,7 +386,7 @@ static u8 nfit_dsm_revid(unsigned family, unsigned func)
386386

387387
if (family > NVDIMM_FAMILY_MAX)
388388
return 0;
389-
if (func > 31)
389+
if (func > NVDIMM_CMD_MAX)
390390
return 0;
391391
id = revid_table[family][func];
392392
if (id == 0)
@@ -492,7 +492,8 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
492492
* Check for a valid command. For ND_CMD_CALL, we also have to
493493
* make sure that the DSM function is supported.
494494
*/
495-
if (cmd == ND_CMD_CALL && !test_bit(func, &dsm_mask))
495+
if (cmd == ND_CMD_CALL &&
496+
(func > NVDIMM_CMD_MAX || !test_bit(func, &dsm_mask)))
496497
return -ENOTTY;
497498
else if (!test_bit(cmd, &cmd_mask))
498499
return -ENOTTY;
@@ -3494,7 +3495,8 @@ static int acpi_nfit_clear_to_send(struct nvdimm_bus_descriptor *nd_desc,
34943495
if (nvdimm && cmd == ND_CMD_CALL &&
34953496
call_pkg->nd_family == NVDIMM_FAMILY_INTEL) {
34963497
func = call_pkg->nd_command;
3497-
if ((1 << func) & NVDIMM_INTEL_SECURITY_CMDMASK)
3498+
if (func > NVDIMM_CMD_MAX ||
3499+
(1 << func) & NVDIMM_INTEL_SECURITY_CMDMASK)
34983500
return -EOPNOTSUPP;
34993501
}
35003502

drivers/acpi/nfit/nfit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
| ACPI_NFIT_MEM_NOT_ARMED | ACPI_NFIT_MEM_MAP_FAILED)
3535

3636
#define NVDIMM_FAMILY_MAX NVDIMM_FAMILY_HYPERV
37+
#define NVDIMM_CMD_MAX 31
3738

3839
#define NVDIMM_STANDARD_CMDMASK \
3940
(1 << ND_CMD_SMART | 1 << ND_CMD_SMART_THRESHOLD | 1 << ND_CMD_DIMM_FLAGS \

drivers/nvdimm/bus.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,8 +1042,10 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm,
10421042
return -EFAULT;
10431043
}
10441044

1045-
if (!desc || (desc->out_num + desc->in_num == 0) ||
1046-
!test_bit(cmd, &cmd_mask))
1045+
if (!desc ||
1046+
(desc->out_num + desc->in_num == 0) ||
1047+
cmd > ND_CMD_CALL ||
1048+
!test_bit(cmd, &cmd_mask))
10471049
return -ENOTTY;
10481050

10491051
/* fail write commands (when read-only) */

tools/testing/nvdimm/Kbuild

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ DRIVERS := ../../../drivers
2121
NVDIMM_SRC := $(DRIVERS)/nvdimm
2222
ACPI_SRC := $(DRIVERS)/acpi/nfit
2323
DAX_SRC := $(DRIVERS)/dax
24-
ccflags-y := -I$(src)/$(NVDIMM_SRC)/
25-
ccflags-y += -I$(src)/$(ACPI_SRC)/
24+
ccflags-y := -I$(srctree)/drivers/nvdimm/
25+
ccflags-y += -I$(srctree)/drivers/acpi/nfit/
2626

2727
obj-$(CONFIG_LIBNVDIMM) += libnvdimm.o
2828
obj-$(CONFIG_BLK_DEV_PMEM) += nd_pmem.o

tools/testing/nvdimm/test/Kbuild

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SPDX-License-Identifier: GPL-2.0
2-
ccflags-y := -I$(src)/../../../../drivers/nvdimm/
3-
ccflags-y += -I$(src)/../../../../drivers/acpi/nfit/
2+
ccflags-y := -I$(srctree)/drivers/nvdimm/
3+
ccflags-y += -I$(srctree)/drivers/acpi/nfit/
44

55
obj-m += nfit_test.o
66
obj-m += nfit_test_iomap.o

tools/testing/nvdimm/test/nfit.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3164,7 +3164,9 @@ static __init int nfit_test_init(void)
31643164
mcsafe_test();
31653165
dax_pmem_test();
31663166
dax_pmem_core_test();
3167+
#ifdef CONFIG_DEV_DAX_PMEM_COMPAT
31673168
dax_pmem_compat_test();
3169+
#endif
31683170

31693171
nfit_test_setup(nfit_test_lookup, nfit_test_evaluate_dsm);
31703172

0 commit comments

Comments
 (0)