aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nvdimm/namespace_devs.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2017-06-06 11:39:30 -0700
committerDan Williams <dan.j.williams@intel.com>2017-06-15 14:31:40 -0700
commit8f2bc2430e4ec53ea961997d760c3b35f729e444 (patch)
treeb22d8530aca1b1c470c34f6ae46110f030bc4198 /drivers/nvdimm/namespace_devs.c
parentlibnvdimm, label: populate the type_guid property for v1.2 namespaces (diff)
downloadlinux-dev-8f2bc2430e4ec53ea961997d760c3b35f729e444.tar.xz
linux-dev-8f2bc2430e4ec53ea961997d760c3b35f729e444.zip
libnvdimm, label: populate 'isetcookie' for blk-aperture namespaces
Starting with the v1.2 definition of namespace labels, the isetcookie field is populated and validated for blk-aperture namespaces. This adds some safety against inadvertent copying of namespace labels from one DIMM-device to another. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/nvdimm/namespace_devs.c')
-rw-r--r--drivers/nvdimm/namespace_devs.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index e101aec186c7..7aba9a569c8e 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -2065,12 +2065,20 @@ struct device *create_namespace_blk(struct nd_region *nd_region,
struct device *dev = NULL;
struct resource *res;
- if (namespace_label_has(ndd, type_guid)
- && !guid_equal(&nd_set->type_guid,
- &nd_label->type_guid)) {
- dev_dbg(ndd->dev, "expect type_guid %pUb got %pUb\n",
- nd_set->type_guid.b, nd_label->type_guid.b);
- return ERR_PTR(-EAGAIN);
+ if (namespace_label_has(ndd, type_guid)) {
+ if (!guid_equal(&nd_set->type_guid, &nd_label->type_guid)) {
+ dev_dbg(ndd->dev, "expect type_guid %pUb got %pUb\n",
+ nd_set->type_guid.b,
+ nd_label->type_guid.b);
+ return ERR_PTR(-EAGAIN);
+ }
+
+ if (nd_label->isetcookie != __cpu_to_le64(nd_set->cookie2)) {
+ dev_dbg(ndd->dev, "expect cookie %#llx got %#llx\n",
+ nd_set->cookie2,
+ __le64_to_cpu(nd_label->isetcookie));
+ return ERR_PTR(-EAGAIN);
+ }
}
nsblk = kzalloc(sizeof(*nsblk), GFP_KERNEL);