Merge branch 'for-5.11/dax' into for-5.11/libnvdimm
authorDan Williams <dan.j.williams@intel.com>
Thu, 24 Dec 2020 18:14:04 +0000 (10:14 -0800)
committerDan Williams <dan.j.williams@intel.com>
Thu, 24 Dec 2020 18:14:04 +0000 (10:14 -0800)
Pull in miscellaneous device-dax fixups and cleanups for v5.11.

drivers/acpi/nfit/core.c
drivers/nvdimm/btt.h
drivers/nvdimm/claim.c
drivers/nvdimm/core.c
drivers/nvdimm/label.c

index 4426082..b11b08a 100644 (file)
@@ -5,6 +5,7 @@
 #include <linux/list_sort.h>
 #include <linux/libnvdimm.h>
 #include <linux/module.h>
+#include <linux/nospec.h>
 #include <linux/mutex.h>
 #include <linux/ndctl.h>
 #include <linux/sysfs.h>
@@ -282,18 +283,19 @@ err:
 
 static union acpi_object *int_to_buf(union acpi_object *integer)
 {
-       union acpi_object *buf = ACPI_ALLOCATE(sizeof(*buf) + 4);
+       union acpi_object *buf = NULL;
        void *dst = NULL;
 
-       if (!buf)
-               goto err;
-
        if (integer->type != ACPI_TYPE_INTEGER) {
                WARN_ONCE(1, "BIOS bug, unexpected element type: %d\n",
                                integer->type);
                goto err;
        }
 
+       buf = ACPI_ALLOCATE(sizeof(*buf) + 4);
+       if (!buf)
+               goto err;
+
        dst = buf + 1;
        buf->type = ACPI_TYPE_BUFFER;
        buf->buffer.length = 4;
@@ -478,8 +480,11 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
                cmd_mask = nd_desc->cmd_mask;
                if (cmd == ND_CMD_CALL && call_pkg->nd_family) {
                        family = call_pkg->nd_family;
-                       if (!test_bit(family, &nd_desc->bus_family_mask))
+                       if (family > NVDIMM_BUS_FAMILY_MAX ||
+                           !test_bit(family, &nd_desc->bus_family_mask))
                                return -EINVAL;
+                       family = array_index_nospec(family,
+                                                   NVDIMM_BUS_FAMILY_MAX + 1);
                        dsm_mask = acpi_desc->family_dsm_mask[family];
                        guid = to_nfit_bus_uuid(family);
                } else {
index 2e258be..aa53e0b 100644 (file)
@@ -7,7 +7,6 @@
 #ifndef _LINUX_BTT_H
 #define _LINUX_BTT_H
 
-#include <linux/badblocks.h>
 #include <linux/types.h>
 
 #define BTT_SIG_LEN 16
@@ -197,6 +196,8 @@ struct arena_info {
        int log_index[2];
 };
 
+struct badblocks;
+
 /**
  * struct btt - handle for a BTT instance
  * @btt_disk:          Pointer to the gendisk for BTT device
index 5a7c800..030dbde 100644 (file)
@@ -4,6 +4,7 @@
  */
 #include <linux/device.h>
 #include <linux/sizes.h>
+#include <linux/badblocks.h>
 #include "nd-core.h"
 #include "pmem.h"
 #include "pfn.h"
index c21ba06..7de592d 100644 (file)
@@ -3,7 +3,6 @@
  * Copyright(c) 2013-2015 Intel Corporation. All rights reserved.
  */
 #include <linux/libnvdimm.h>
-#include <linux/badblocks.h>
 #include <linux/suspend.h>
 #include <linux/export.h>
 #include <linux/module.h>
index 47a4828..9251441 100644 (file)
@@ -980,6 +980,15 @@ static int __blk_label_update(struct nd_region *nd_region,
                }
        }
 
+       /* release slots associated with any invalidated UUIDs */
+       mutex_lock(&nd_mapping->lock);
+       list_for_each_entry_safe(label_ent, e, &nd_mapping->labels, list)
+               if (test_and_clear_bit(ND_LABEL_REAP, &label_ent->flags)) {
+                       reap_victim(nd_mapping, label_ent);
+                       list_move(&label_ent->list, &list);
+               }
+       mutex_unlock(&nd_mapping->lock);
+
        /*
         * Find the resource associated with the first label in the set
         * per the v1.2 namespace specification.
@@ -999,8 +1008,10 @@ static int __blk_label_update(struct nd_region *nd_region,
                if (is_old_resource(res, old_res_list, old_num_resources))
                        continue; /* carry-over */
                slot = nd_label_alloc_slot(ndd);
-               if (slot == UINT_MAX)
+               if (slot == UINT_MAX) {
+                       rc = -ENXIO;
                        goto abort;
+               }
                dev_dbg(ndd->dev, "allocated: %d\n", slot);
 
                nd_label = to_label(ndd, slot);