lkml.org 
[lkml]   [2022]   [Jan]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.16 0450/1039] RDMA/hns: Validate the pkey index
    Date
    From: Kamal Heib <kamalheib1@gmail.com>

    [ Upstream commit 2a67fcfa0db6b4075515bd23497750849b88850f ]

    Before query pkey, make sure that the queried index is valid.

    Fixes: 9a4435375cd1 ("IB/hns: Add driver files for hns RoCE driver")
    Link: https://lore.kernel.org/r/20211117145954.123893-1-kamalheib1@gmail.com
    Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/infiniband/hw/hns/hns_roce_main.c | 3 +++
    1 file changed, 3 insertions(+)

    diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c
    index 4194b626f3c65..8233bec053ee3 100644
    --- a/drivers/infiniband/hw/hns/hns_roce_main.c
    +++ b/drivers/infiniband/hw/hns/hns_roce_main.c
    @@ -270,6 +270,9 @@ static enum rdma_link_layer hns_roce_get_link_layer(struct ib_device *device,
    static int hns_roce_query_pkey(struct ib_device *ib_dev, u32 port, u16 index,
    u16 *pkey)
    {
    + if (index > 0)
    + return -EINVAL;
    +
    *pkey = PKEY_ID;

    return 0;
    --
    2.34.1


    \
     
     \ /
      Last update: 2022-01-24 23:10    [W:2.852 / U:0.428 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site