OSDN Git Service

RDMA/core: Verify that memory window type is legal
authorNoa Osherovich <noaos@mellanox.com>
Tue, 19 Feb 2019 13:07:34 +0000 (15:07 +0200)
committerJason Gunthorpe <jgg@mellanox.com>
Wed, 20 Feb 2019 03:52:19 +0000 (20:52 -0700)
Before calling the provider's alloc_mw function, verify that the
given memory type is either IB_MW_TYPE_1 or IB_MW_TYPE_2.

Signed-off-by: Noa Osherovich <noaos@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/core/uverbs_cmd.c

index 6baafa1..6fcfaca 100644 (file)
@@ -885,6 +885,11 @@ static int ib_uverbs_alloc_mw(struct uverbs_attr_bundle *attrs)
                goto err_free;
        }
 
+       if (cmd.mw_type != IB_MW_TYPE_1 && cmd.mw_type != IB_MW_TYPE_2) {
+               ret = -EINVAL;
+               goto err_put;
+       }
+
        mw = pd->device->ops.alloc_mw(pd, cmd.mw_type, &attrs->driver_udata);
        if (IS_ERR(mw)) {
                ret = PTR_ERR(mw);