summaryrefslogtreecommitdiff
path: root/drivers/nvme/host/lightnvm.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2016-03-08 09:49:43 (GMT)
committerTakashi Iwai <tiwai@suse.de>2016-03-08 09:49:43 (GMT)
commit56d94d70398f0fbb1863a03a145db1a86f009a71 (patch)
tree9e52dc537f8f8359c70b66f5000192bb280b41b9 /drivers/nvme/host/lightnvm.c
parentbb63f726f98bec032c7322a9c36eb4167307d856 (diff)
parentfc4f000bf8c0cbf38f44de6bd5e225574e572ed4 (diff)
downloadlinux-56d94d70398f0fbb1863a03a145db1a86f009a71.tar.xz
Merge branch 'topic/hda' into for-next
Diffstat (limited to 'drivers/nvme/host/lightnvm.c')
-rw-r--r--drivers/nvme/host/lightnvm.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c
index 5cd3725..6bb15e4 100644
--- a/drivers/nvme/host/lightnvm.c
+++ b/drivers/nvme/host/lightnvm.c
@@ -146,9 +146,10 @@ struct nvme_nvm_command {
};
};
+#define NVME_NVM_LP_MLC_PAIRS 886
struct nvme_nvm_lp_mlc {
__u16 num_pairs;
- __u8 pairs[886];
+ __u8 pairs[NVME_NVM_LP_MLC_PAIRS];
};
struct nvme_nvm_lp_tbl {
@@ -282,9 +283,14 @@ static int init_grps(struct nvm_id *nvm_id, struct nvme_nvm_id *nvme_nvm_id)
memcpy(dst->lptbl.id, src->lptbl.id, 8);
dst->lptbl.mlc.num_pairs =
le16_to_cpu(src->lptbl.mlc.num_pairs);
- /* 4 bits per pair */
+
+ if (dst->lptbl.mlc.num_pairs > NVME_NVM_LP_MLC_PAIRS) {
+ pr_err("nvm: number of MLC pairs not supported\n");
+ return -EINVAL;
+ }
+
memcpy(dst->lptbl.mlc.pairs, src->lptbl.mlc.pairs,
- dst->lptbl.mlc.num_pairs >> 1);
+ dst->lptbl.mlc.num_pairs);
}
}