Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1552797pxb; Thu, 16 Sep 2021 09:46:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWy5FWVbsiyVNuipmGc4F3WgQL+neLt+Xual+7YtYEI3mQII13gK+WPdvtLYlfhMng1tWi X-Received: by 2002:a17:906:180a:: with SMTP id v10mr7359915eje.112.1631810774021; Thu, 16 Sep 2021 09:46:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631810774; cv=none; d=google.com; s=arc-20160816; b=wbWQx2wWidzEqKVes40fVpPBpAZ5OxaOye3x66OVf8x4V4Nz085OIlRvlrXXmogP+M fQ2dKsJ6ndW9zEuJKClHsHmTOEjtVdHhT6RHpgscw5qn/258Or8UKAjrRLysJs4DepY0 NHhhkDBvFB28rBDpV65R97o+Zgaa/gW+5vUs3dZc74v36Mo7/aQQw/tw6F7nKJSRrdiH KASs8fge8deLFuJD6+2v9x9KP6emtJ/u1XIloOrUxA9ZcIMqhKn9dgI7RVNudi1UAsv/ 9PFgfHdW8kiZXvK0ccarkWUWHIt1cRpFc8U0fAdNrMp0AmKGVui9eS8uf2GcgUn++YhD UKbg== 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=wE5CvsPeWQYYBKHqopXS7dI7ktO9eg/67xja55BunP8=; b=g6Dd+bsyTvaCa2njnJiabGWRs/lv5tu+6Nd0TIeNl/f89c/jhsfJWYKU0tDsBZBFwW JAEvPVlE1TzhltWnLcVs2oTqEbNZxzq99ohODIK4Zfwm5pm3nMtJSuJKEc1eJy2Eekzu z4l54ytyyVLsK7oXQlOnsk6a4PYQekLXRiamiSfrqHMTxXlQBFbJ0eKIdi0J7YvX9zzV MC+QSUrpXLHynGrh712rj6ugDUOT60lIr5/iWYQZGGmlTzf/ZGEijdweLGi/OfurzulJ ZtKvj3U9BYPBl1b2UgwWHb/4CKveeqJrhir588hjtPw/MGeJhEbix9n5i9umH8PRdBIL D3sA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SylsZOzW; 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 eb8si35099edb.406.2021.09.16.09.45.48; Thu, 16 Sep 2021 09:46:14 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SylsZOzW; 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 S1343886AbhIPQoS (ORCPT + 99 others); Thu, 16 Sep 2021 12:44:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:51236 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244477AbhIPQhK (ORCPT ); Thu, 16 Sep 2021 12:37:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E11F3613A4; Thu, 16 Sep 2021 16:22:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631809325; bh=ZEgoRxvxiugElWLqHfRlMZffpNpHjzFe/sMyW4PK2Xs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SylsZOzWEAn+R0No4GRWCABCoFxmfdtRI6ajdYVvDgao8ko9+ruVHv+hKwVJbMOtU Q7iLWgv+Zpvgx0eXgKs+6qBbBKXkUx8OiHjnlfDvRY0vvNacjeSqfOJOSIlcBKFLTc ke4lE/Ankngm+gVAG89Yz/9U+PpDuB3LOUigKhUE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Manish Rangankar , Dan Carpenter , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.13 106/380] scsi: qedf: Fix error codes in qedf_alloc_global_queues() Date: Thu, 16 Sep 2021 17:57:43 +0200 Message-Id: <20210916155807.650939575@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155803.966362085@linuxfoundation.org> References: <20210916155803.966362085@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: Dan Carpenter [ Upstream commit ccc89737aa6b9f248cf1623014038beb6c2b7f56 ] This driver has some left over "return 1" on failure style code mixed with "return negative error codes" style code. The caller doesn't care so we should just convert everything to return negative error codes. Then there was a problem that there were two variables used to store error codes which just resulted in confusion. If qedf_alloc_bdq() returned a negative error code, we accidentally returned success instead of propagating the error code. So get rid of the "rc" variable and use "status" every where. Also remove the "status = 0" initialization so that these sorts of bugs will be detected by the compiler in the future. Link: https://lore.kernel.org/r/20210810085023.GA23998@kili Fixes: 61d8658b4a43 ("scsi: qedf: Add QLogic FastLinQ offload FCoE driver framework.") Acked-by: Manish Rangankar Signed-off-by: Dan Carpenter Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/qedf/qedf_main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index b92570a7c309..98981a61b012 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -3000,7 +3000,7 @@ static int qedf_alloc_global_queues(struct qedf_ctx *qedf) { u32 *list; int i; - int status = 0, rc; + int status; u32 *pbl; dma_addr_t page; int num_pages; @@ -3012,7 +3012,7 @@ static int qedf_alloc_global_queues(struct qedf_ctx *qedf) */ if (!qedf->num_queues) { QEDF_ERR(&(qedf->dbg_ctx), "No MSI-X vectors available!\n"); - return 1; + return -ENOMEM; } /* @@ -3020,7 +3020,7 @@ static int qedf_alloc_global_queues(struct qedf_ctx *qedf) * addresses of our queues */ if (!qedf->p_cpuq) { - status = 1; + status = -EINVAL; QEDF_ERR(&qedf->dbg_ctx, "p_cpuq is NULL.\n"); goto mem_alloc_failure; } @@ -3036,8 +3036,8 @@ static int qedf_alloc_global_queues(struct qedf_ctx *qedf) "qedf->global_queues=%p.\n", qedf->global_queues); /* Allocate DMA coherent buffers for BDQ */ - rc = qedf_alloc_bdq(qedf); - if (rc) { + status = qedf_alloc_bdq(qedf); + if (status) { QEDF_ERR(&qedf->dbg_ctx, "Unable to allocate bdq.\n"); goto mem_alloc_failure; } -- 2.30.2