From patchwork Sat Apr 22 10:16:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peizhi Li X-Patchwork-Id: 676263 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8EA37C6FD18 for ; Sat, 22 Apr 2023 10:17:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229612AbjDVKRo (ORCPT ); Sat, 22 Apr 2023 06:17:44 -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 X-FEAS-AUTH-USER: meetlpz@hust.edu.cn Precedence: bulk List-ID: X-Mailing-List: linux-scsi@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 Acked-by: Manish Rangankar Reviewed-by: Mike Christie --- 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 *) *