diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 32e08f287602f9511336a52c921fd519a7a0cf8c..142f3a03509cb724f1a42a334c128c6b450c4b72 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -966,9 +966,13 @@ static void *nvme_add_user_metadata(struct bio *bio, void __user *ubuf, if (!buf) goto out; - ret = -EFAULT; - if (write && copy_from_user(buf, ubuf, len)) - goto out_free_meta; + if (write) { + ret = -EFAULT; + if (copy_from_user(buf, ubuf, len)) + goto out_free_meta; + } else { + memset(buf, 0, len); + } bip = bio_integrity_alloc(bio, GFP_KERNEL, 1); if (IS_ERR(bip)) {