Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3578875pxb; Mon, 24 Jan 2022 12:41:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJxTGoNcIh3GRqur5GtFg/dacv7yWge8rbE0DeOlTLkTXpF7J0swsemOxz6om5b4A4utprrx X-Received: by 2002:a17:90a:69a1:: with SMTP id s30mr35113pjj.71.1643056871915; Mon, 24 Jan 2022 12:41:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643056871; cv=none; d=google.com; s=arc-20160816; b=QscOVXjHmEuxP3rcr2lnveS5Y5XWO9RY10uPheyBPLG7ZrmMPOjl/c1eG2shs6yEE8 BgcVyHJN9CvMte3V59cxQtptPN7qps0OAaO444SrScZ6mpiuWyalbO8/J6arNC5ikTnH P9FxqjokyjBQP2Y30sfFjaJE8EF/s4BIKxW1idkSlhUz8PXg6Sbz6CT4d5s3XawYiO4W XPG5bfxVVnH8DZ/HM8Gxjx41iwR+rkyV2FnQ1jNtxjgy2/XY6CAsR5i5rct/2VaV5R62 Yn0vNE0L8ZkGp1NzaFrduGc08XhknSVf7v3U5FYbKYvHgoAuJbkiPHEOc6GUyy0i+qmA hg0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=X5Km8MHbUpjADDW3AIccEEDcAjAUDpmHOodHgmZSX8k=; b=Hu0VAthi02ngI4AcZ3v35s32O7tTcVJJj3RqtPIdGvpnYRNXMupY9cDuI5XNIjEIj9 G7ZQ//CzL4wxiRj10RQM4s5AxA6F0cj5X5SGJjNgSN9n5TKaB+kznLGuPorCHopYrXRx IA1LJa+CLxwDfdCnXM0HmCxINCeCuwArUvqf1aX1ooghnog9phLByZ8oqimwEHnyysfj 25N+AX1GlD1gSVRN6F4cJ7dhSR8mtpmi94o2jsX/sNuez3xoEDXtXBgDKHeC+/ucmzZb H9ojGGJsZBR9prSmJ8cFBklvi286w2cYrklkppbw1AyMhWYG37zG6HWbv4qXsoO3krR8 ccjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gsb1bnPW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e21si10455010pgj.698.2022.01.24.12.40.57; Mon, 24 Jan 2022 12:41:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gsb1bnPW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359153AbiAXT43 (ORCPT + 99 others); Mon, 24 Jan 2022 14:56:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349667AbiAXThT (ORCPT ); Mon, 24 Jan 2022 14:37:19 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FB4EC03400B; Mon, 24 Jan 2022 11:17:20 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C9C0AB8121A; Mon, 24 Jan 2022 19:17:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D898C340E5; Mon, 24 Jan 2022 19:17:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643051838; bh=Qv3iaepdUWUPB8G3RKHiXJh6nOrf8T5JCWPTQVoXFDA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gsb1bnPW53q9csd4VzVtWuff//depYjG/LkiqmV7AtMFAm56cZ5yj9zLr7ZlZVwAW +I0e3t/8G4peXWl9XPKVpyAmrN7dQQAWJ6D9JBKivbPBTNRN8JtJivhOhC56ocQzpo BsUT6lRurOVONtwU+VwdOAUmvinkD/di2eB73A+s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kamal Heib , Jason Gunthorpe , Sasha Levin Subject: [PATCH 4.19 102/239] RDMA/hns: Validate the pkey index Date: Mon, 24 Jan 2022 19:42:20 +0100 Message-Id: <20220124183946.346995735@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183943.102762895@linuxfoundation.org> References: <20220124183943.102762895@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kamal Heib [ 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 Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- 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 c5cae9a38c044..5e60a2596d2bf 100644 --- a/drivers/infiniband/hw/hns/hns_roce_main.c +++ b/drivers/infiniband/hw/hns/hns_roce_main.c @@ -295,6 +295,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, u8 port, u16 index, u16 *pkey) { + if (index > 0) + return -EINVAL; + *pkey = PKEY_ID; return 0; -- 2.34.1