On 04/09/2019 10:15, Michal Kalderon wrote: > static int __efa_mmap(struct efa_dev *dev, struct efa_ucontext *ucontext, > - struct vm_area_struct *vma, u64 key, u64 length) > + struct vm_area_struct *vma, u64 key, size_t length) > { > - struct efa_mmap_entry *entry; > + struct rdma_user_mmap_entry *rdma_entry; > + struct efa_user_mmap_entry *entry; > unsigned long va; > u64 pfn; > int err; > > - entry = mmap_entry_get(dev, ucontext, key, length); > - if (!entry) { > + rdma_entry = rdma_user_mmap_entry_get(&ucontext->ibucontext, key, > + length, vma); > + if (!rdma_entry) { > ibdev_dbg(&dev->ibdev, "key[%#llx] does not have valid entry\n", > key); > return -EINVAL; > } > + entry = to_emmap(rdma_entry); > + if (entry->length != length) { > + ibdev_dbg(&dev->ibdev, > + "key[%#llx] does not have valid length[%#zx] expected[%#zx]\n", > + key, length, entry->length); > + err = -EINVAL; > + goto err; > + } > > ibdev_dbg(&dev->ibdev, > - "Mapping address[%#llx], length[%#llx], mmap_flag[%d]\n", > - entry->address, length, entry->mmap_flag); > + "Mapping address[%#llx], length[%#zx], mmap_flag[%d]\n", > + entry->address, entry->length, entry->mmap_flag); > > pfn = entry->address >> PAGE_SHIFT; > switch (entry->mmap_flag) { > @@ -1630,15 +1623,16 @@ static int __efa_mmap(struct efa_dev *dev, struct efa_ucontext *ucontext, > err = -EINVAL; > } > > - if (err) { > - ibdev_dbg( > - &dev->ibdev, > - "Couldn't mmap address[%#llx] length[%#llx] mmap_flag[%d] err[%d]\n", > - entry->address, length, entry->mmap_flag, err); > - return err; > - } > + if (err) > + goto err; Thanks Michal, Acked-by: Gal Pressman <galpress@xxxxxxxxxx> If you're planning on doing another cycle, this error path now prints nothing, I meant move the print from the goto inside this if (before goto err). > > return 0; > + > +err: > + rdma_user_mmap_entry_put(&ucontext->ibucontext, > + rdma_entry); > + > + return err; > }