Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1981915ybh; Fri, 24 Jul 2020 01:08:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrAoY15nIw9qq69x8M0LYekwk81kr0HMXeVKabzimujym3SvhrMowicx+A0Ds/S01mlmQ4 X-Received: by 2002:aa7:d7cf:: with SMTP id e15mr8011455eds.236.1595578085809; Fri, 24 Jul 2020 01:08:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595578085; cv=none; d=google.com; s=arc-20160816; b=YWXyN9z/8s2FjP81zqRBdwxtIHZk1Rjl0llnYt0IJb9QYx8fhtIwjPcL3O4Fsm54fC 28mdIfT/HFUeNgaINM8mq4fWz+/tcgBzkD+CnXohA8LOJet9JSrZ3CeFa3i5d/luTmNi vtNae6DZndNAqdzfe95MZyf9Hl6/L/t6iWKpT77IBrZXiBb6QWBXUKLoKWASaeFfXPC6 srgIT/22m19RqcYpi6zM6WjQB0IrzS5knSCzj61/x1Y+0dMiXiZGWeHwKzlivLUvApgF O7xmnz/GvHXn603xN+hr/6jwUStKnC9uvYgPJYKOq/wtDEl+cim+7kkABehCNchtJRG4 OJcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=dfGd+e7sdNnyTINxUhNvQJPGM3i2YXpZDoh8bBhlC2Y=; b=PQzOHGj8XlS21ZurPKqeBJBGLAKaZWu4Ix38ogL5Gjetdh1ZbvRkyx6FVw7Y2dXVO/ SwccgwmeUvVfj6nXtBnxoKgHLcbiqn0Kp8WeZa3fkkzKLJvGWfmm66lpKjhQQqyOF6O3 2/u6679hWV4C7hOuhLyrX72hKU3AOu152t5FLZ7Dpaeo/+vRady3gsH0imGSlxjM6gNC eqZm9kmV8Bf3wVi9dWV7pSkavcbbAxkT+dK+tU7Ofp21s+lruFFCUZEQidrB2msyEY/A WNmYSqHVBfSF+r8N4ww9NU2k8NghoH48trhL7G0IQK18fJ2P+y3nySkWI9vcGfMenHEz q8MA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z14si126937ejw.332.2020.07.24.01.07.42; Fri, 24 Jul 2020 01:08:05 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726826AbgGXIH1 (ORCPT + 99 others); Fri, 24 Jul 2020 04:07:27 -0400 Received: from mail.zju.edu.cn ([61.164.42.155]:17430 "EHLO zju.edu.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726572AbgGXIH0 (ORCPT ); Fri, 24 Jul 2020 04:07:26 -0400 Received: from localhost.localdomain (unknown [210.32.144.186]) by mail-app4 (Coremail) with SMTP id cS_KCgAHiPyplhpfXiRFAA--.33653S4; Fri, 24 Jul 2020 16:07:09 +0800 (CST) From: Dinghao Liu To: dinghao.liu@zju.edu.cn, kjlu@umn.edu Cc: Sunil Goutham , Linu Cherian , Geetha sowjanya , Jerin Jacob , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] octeontx2-af: Fix use of uninitialized pointer bmap Date: Fri, 24 Jul 2020 16:06:57 +0800 Message-Id: <20200724080657.19182-1-dinghao.liu@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: cS_KCgAHiPyplhpfXiRFAA--.33653S4 X-Coremail-Antispam: 1UD129KBjvJXoW7tw17Wr47KF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qrrzjiaqtzq6lmxovvfxof0/1tbiAggHBlZdtPRcawAPs4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If req->ctype does not match any of NIX_AQ_CTYPE_CQ, NIX_AQ_CTYPE_SQ or NIX_AQ_CTYPE_RQ, pointer bmap will remain uninitialized and be accessed in test_bit(), which can lead to kernal crash. Fix this by returning an error code if this case is triggered. Signed-off-by: Dinghao Liu --- drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c index 36953d4f51c7..20a64ed24474 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c @@ -869,19 +869,18 @@ static int nix_lf_hwctx_disable(struct rvu *rvu, struct hwctx_disable_req *req) aq_req.cq_mask.bp_ena = 1; q_cnt = pfvf->cq_ctx->qsize; bmap = pfvf->cq_bmap; - } - if (req->ctype == NIX_AQ_CTYPE_SQ) { + } else if (req->ctype == NIX_AQ_CTYPE_SQ) { aq_req.sq.ena = 0; aq_req.sq_mask.ena = 1; q_cnt = pfvf->sq_ctx->qsize; bmap = pfvf->sq_bmap; - } - if (req->ctype == NIX_AQ_CTYPE_RQ) { + } else if (req->ctype == NIX_AQ_CTYPE_RQ) { aq_req.rq.ena = 0; aq_req.rq_mask.ena = 1; q_cnt = pfvf->rq_ctx->qsize; bmap = pfvf->rq_bmap; - } + } else + return NIX_AF_ERR_AQ_ENQUEUE; aq_req.ctype = req->ctype; aq_req.op = NIX_AQ_INSTOP_WRITE; -- 2.17.1