Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp3330229rwr; Sat, 22 Apr 2023 03:19:48 -0700 (PDT) X-Google-Smtp-Source: AKy350ZJvS9eFsMufDDRXlzAtEC0lNuOjXVVhstuQcpSn61kLyme/DIqUpsagg6AL2pIiTnEEw1V X-Received: by 2002:a17:902:ea0d:b0:1a6:3ba2:c896 with SMTP id s13-20020a170902ea0d00b001a63ba2c896mr9670368plg.3.1682158787897; Sat, 22 Apr 2023 03:19:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682158787; cv=none; d=google.com; s=arc-20160816; b=unytVuKLKl2jwpvUeLF08EkSf9hk7n1uu1yY9ddDW9FDahl1A8bh8r5aSyo3lmDNDB 6p6x8nephbAqw9B+xkkr9W04bN7vxrWzxPyhGetkP37ENyGxoIW99TmuPl3dyELPs0VB Uz3O8WfpN2meLNHFiD/faTf7UP4RDHr3m/vhM5i3VBrO8ttPi2ggipaIXIcD2dHPxveZ 82nAblBMKynABX+o+vw7TYYF9IIrAKBX4gl1FjH0wqce82oRtu81zKMlw9hWN+xxkAkl cFatGNf81x/K1Q75NkWxsJBiLWRaCTDZbDcDhBC0Ob0+Qy2SPXDvSVoyC3zNkTJAmhId 8Zvw== 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 :message-id:date:subject:cc:to:from; bh=DqapFV36UxZxogqqkOJLyf/1S6qhGgrLR1R1EQyi+5Q=; b=ubEJbIRF+vtaIzXkulQfMoYfJiNaGn21AB3QEvzZCBwKh751DYoaDVdi3VdOecqxoK gJVCae5pW63NPMOhfylbATn2/A4UXUPP6RSiYxW/nqBmsLgrvnL/EsEW5VE12Kev8v8H gFUlO7god3USUqdAzRoWuSMAZ+txBq7fOEFiIvjCTLjqd8LerwC3HJS6/tI89SQkm6bp q6EJ4tPehTXmCmrfyHP8ZQZdiEor3JdAJjw6RrDQUVeeu35ixtAyrUud529LkQ3+4GIM dFz3uto1U22u0q3gse9GCDysQXS1YGOo9TP1ITVT6Tx7tDBKet01eoso2hgnagnpoygv gDig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jl17-20020a170903135100b001a6386f39bfsi6085517plb.186.2023.04.22.03.19.33; Sat, 22 Apr 2023 03:19:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229644AbjDVKRp (ORCPT + 99 others); Sat, 22 Apr 2023 06:17:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229583AbjDVKRn (ORCPT ); Sat, 22 Apr 2023 06:17:43 -0400 Received: from hust.edu.cn (unknown [202.114.0.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 335C41FC3; Sat, 22 Apr 2023 03:17:29 -0700 (PDT) Received: from localhost.localdomain ([172.16.0.254]) (user=meetlpz@hust.edu.cn mech=LOGIN bits=0) by mx1.hust.edu.cn with ESMTP id 33MAGTwg005986-33MAGTwh005986 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Sat, 22 Apr 2023 18:16:37 +0800 From: Peizhi Li To: Nilesh Javali , Manish Rangankar , GR-QLogic-Storage-Upstream@marvell.com, "James E.J. Bottomley" , "Martin K. Petersen" Cc: hust-os-kernel-patches@googlegroups.com, Peizhi Li , Dongliang Mu , Dan Carpenter , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] scsi: qedi: qedi_main.c: modify the code flow in 'qedi_alloc_global_queues' Date: Sat, 22 Apr 2023 18:16:26 +0800 Message-Id: <20230422101626.1722235-1-meetlpz@hust.edu.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-FEAS-AUTH-USER: meetlpz@hust.edu.cn X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When goto the mem_alloc_failure, it will result in a null pointer reference to variable 'gl' in function 'qedi_free_global_queues', due to the 'qedi->global_queues' not being allocated. Fix this by returning -EINVAL directly. Signed-off-by: Peizhi Li Reviewed-by: Dongliang Mu Reviewed-by: Dan Carpenter --- The issue is found by static analysis and remains untested. Meanwhile, this patches is similar with qedf which Jinhong Zhu fixed already. https://lore.kernel.org/all/20230417135518.184595-1-jinhongzhu@hust.edu.cn/ drivers/scsi/qedi/qedi_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c index f2ee49756df8..34f38e0f1c7d 100644 --- a/drivers/scsi/qedi/qedi_main.c +++ b/drivers/scsi/qedi/qedi_main.c @@ -1637,8 +1637,7 @@ static int qedi_alloc_global_queues(struct qedi_ctx *qedi) * addresses of our queues */ if (!qedi->p_cpuq) { - status = -EINVAL; - goto mem_alloc_failure; + return -EINVAL; } qedi->global_queues = kzalloc((sizeof(struct global_queue *) * -- 2.25.1