From patchwork Mon Jun 26 10:58:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 696799 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 D8078EB64DA for ; Mon, 26 Jun 2023 10:58:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230209AbjFZK6V (ORCPT ); Mon, 26 Jun 2023 06:58:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230158AbjFZK6S (ORCPT ); Mon, 26 Jun 2023 06:58:18 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAB6F10EB for ; Mon, 26 Jun 2023 03:58:11 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-313e34ab99fso2318592f8f.1 for ; Mon, 26 Jun 2023 03:58:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687777090; x=1690369090; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=8wTFFYlEacnCLuLIvI9hxugao/WlAGmt8S0+ic9iMMM=; b=HgHm+mJEpvZ08t2fUwrsbQn7G1TAQPnOtjTod7u2J6zZWokbC1xHXBHQfgb/K3Ngio J30pnq4MAgl9hB/gMbnkwGGiIXRDEmR8PMUjeeU5wVSiAJ3akho8u62RrEIYPuxWTLkD HYouB/n1GN55i/CdVd/gTK0FK+i7nFT409vJdlt3/qf33AbNHwup4+3jbF+zmCK+6Nwn OdGEtJahMRpM/9VRFomCUmJ+3KRu9GrC9WTbWqr+moE+yxyz91YZXKt6UKsNKMvQWlki JA7z80ciYtgH2KvY67MQNgUKxlwPlnydgCtrctLNtMXf2qJQyn78djfym5/3othlRqzm ExJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687777090; x=1690369090; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8wTFFYlEacnCLuLIvI9hxugao/WlAGmt8S0+ic9iMMM=; b=SwsBfzdr4BU0qp0aszGniJZKkABa1IXEyaXAq1pVBpjG6Gd32tdyMSb4qxUkT/5V4H rx2ht1HAn+WI6FTdFmjInWxTZMq8b4bkPLFw4itGeOuScqI0HMgq0i8W46iJ40a70qyK 4egwnlZDWYYPSHmP9rsA1FtU0HwXn+ldQKHqdBukIxuvcH8vuEIm7+PUhE6qhFKGJd9O bI5//nG9ww6haw+ws/c01+0SG21Dke6X4PqCAiRVNvjND6/Da5LVsK8oo+1rCY3iAvfy +fJThJcagMbJxr6RIPjKplQmBSTeikt9sSYeRhbMazOtdUdxeWccUzgT1rSg1HRD9Rw8 iM1A== X-Gm-Message-State: AC+VfDznSvPeWELi/MgO0ism0w4+kjeOE1IZes3+uumAxDk8W13KEGtJ WoF0R85wnW/zCV+Mtexv6TF2QA== X-Google-Smtp-Source: ACHHUZ6+fJxWIb0t51vTNh6sIbcojiplFlynzACmCi59wKuqFvI+vy7PihZPoYSE4aMX2eFgChCdnw== X-Received: by 2002:adf:dd88:0:b0:30a:dd15:bb69 with SMTP id x8-20020adfdd88000000b0030add15bb69mr20166780wrl.18.1687777089934; Mon, 26 Jun 2023 03:58:09 -0700 (PDT) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id f4-20020a0560001b0400b00307a86a4bcesm7057546wrz.35.2023.06.26.03.58.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jun 2023 03:58:08 -0700 (PDT) Date: Mon, 26 Jun 2023 13:58:03 +0300 From: Dan Carpenter To: Nilesh Javali Cc: GR-QLogic-Storage-Upstream@marvell.com, "James E.J. Bottomley" , "Martin K. Petersen" , Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-scsi@vger.kernel.org, llvm@lists.linux.dev, kernel-janitors@vger.kernel.org Subject: [PATCH 1/2] scsi: qla2xxx: silence a static checker warning Message-ID: <4aa0485e-766f-4b02-8d5d-c6781ea8f511@moroto.mountain> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Smatch and Clang both complain that LOGIN_TEMPLATE_SIZE is more than sizeof(ha->plogi_els_payld.fl_csp). Smatch warning: drivers/scsi/qla2xxx/qla_iocb.c:3075 qla24xx_els_dcmd2_iocb() warn: '&ha->plogi_els_payld.fl_csp' sometimes too small '16' size = 112 Clang warning: include/linux/fortify-string.h:592:4: error: call to '__read_overflow2_field' declared with 'warning' attribute: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Werror,-Wattribute-warning] __read_overflow2_field(q_size_field, size); When I was reading this code I assumed the "- 4" meant that we were skipping the last 4 bytes but actually it turned out that we are skipping the first four bytes. I have re-written it remove the magic numbers, be more clear and silence the static checker warnings. Signed-off-by: Dan Carpenter --- drivers/scsi/qla2xxx/qla_def.h | 1 - drivers/scsi/qla2xxx/qla_iocb.c | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index d44c4d37b50b..4ae38305c15a 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -4462,7 +4462,6 @@ struct qla_hw_data { /* n2n */ struct fc_els_flogi plogi_els_payld; -#define LOGIN_TEMPLATE_SIZE (sizeof(struct fc_els_flogi) - 4) void *swl; diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index a1675f056a5c..9c70c4e973ee 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c @@ -3073,7 +3073,8 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *vha, int els_opcode, memset(ptr, 0, sizeof(struct els_plogi_payload)); memset(resp_ptr, 0, sizeof(struct els_plogi_payload)); memcpy(elsio->u.els_plogi.els_plogi_pyld->data, - &ha->plogi_els_payld.fl_csp, LOGIN_TEMPLATE_SIZE); + (void *)&ha->plogi_els_payld + offsetof(struct fc_els_flogi, fl_csp), + sizeof(ha->plogi_els_payld) - offsetof(struct fc_els_flogi, fl_csp)); elsio->u.els_plogi.els_cmd = els_opcode; elsio->u.els_plogi.els_plogi_pyld->opcode = els_opcode; From patchwork Mon Jun 26 10:58:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 697138 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 D67E3EB64D7 for ; Mon, 26 Jun 2023 10:59:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229631AbjFZK7N (ORCPT ); Mon, 26 Jun 2023 06:59:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230111AbjFZK7L (ORCPT ); Mon, 26 Jun 2023 06:59:11 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD10C10C8 for ; Mon, 26 Jun 2023 03:58:53 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-313e09a5b19so1583162f8f.0 for ; Mon, 26 Jun 2023 03:58:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687777132; x=1690369132; h=in-reply-to:content-disposition:mime-version:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=NmyUEybaSl8jewhXJwO5GjHWG9G5WP3PmoAzPe0ILkU=; b=avrpOfeIQ3438935VtYjHQuaBm+6uCU1b5BwltsAYwa5QvGk4cE0tbV7j8w+VbT7cu H+SsGvsDgY5AadNGqc6+K3GbYrsGh4guoZFpokrCCR95ax4iusW9hwzPYYGs+MRP8LLh sazU0behMVHCQC9sBhTpjbg9H/mILQaVXUUBXfY62QjQAg82LsIOVCgKkSporXWTHgAK a/P0/lOtjiPorhnOKLPSpMfDUOIGuFzVYZp4Ol6fWNUKgsjUSbzmvEDDr3j7Y9Yb+5rd LwJ4aLomAqL7hxZfvCowL3F+3NYvBYgp8fPKIaWRUmFxJgzIxembueIm5e+XRm0fh8EL aT+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687777132; x=1690369132; h=in-reply-to:content-disposition:mime-version:message-id:subject:cc :to:from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=NmyUEybaSl8jewhXJwO5GjHWG9G5WP3PmoAzPe0ILkU=; b=Gter6ePfsR7P/SbHIvXWgg86rUfJC4G908aYM6mXAyadk1iWtUJKuov9zhwkfdhFF9 JwyGazdilunVHjMEqS41ZC9Xz6u7m13HMKOGbTOWOFbYkYQOluLqiTn+vmbf11D+PYoR w2qgPYU85nuA2ni7PzhUiQ7QtzYqLF3vtvBdn+t3GvDjs5D2pJ+mN0mZoQw9Afp17xcq mFNohin5yPSrI4kFq2yEEMjcoamj0fJScSpWOGKtt2Nhg990LSH+VvRvrnln59F9Mq3f EPKJFyy4HO8ELvr1fpyzLSuTCG9b/scSZvnwt+61d2gSimYFh2lOGF80WNeZlcz2gBTY Y07A== X-Gm-Message-State: AC+VfDxVZHLAnFIlssKB1aThXck9F0rdGDi7eMI5pToPL7yyodpTrsdy 0gnusu3hwdILwrm6ngGks1eCTw== X-Google-Smtp-Source: ACHHUZ5KMnxgiSOOYF9kimp5XVLCW8BXCZswbAvUiPD4AGxmYKKq49SRqCT0jLX3nnllF7SWgh7TDw== X-Received: by 2002:adf:e910:0:b0:30f:c7e5:6176 with SMTP id f16-20020adfe910000000b0030fc7e56176mr26655207wrm.14.1687777132307; Mon, 26 Jun 2023 03:58:52 -0700 (PDT) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id o7-20020adfeac7000000b003095bd71159sm7140636wrn.7.2023.06.26.03.58.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jun 2023 03:58:51 -0700 (PDT) Date: Mon, 26 Jun 2023 13:58:47 +0300 From: Dan Carpenter To: Quinn Tran Cc: Nilesh Javali , GR-QLogic-Storage-Upstream@marvell.com, "James E.J. Bottomley" , "Martin K. Petersen" , Himanshu Madhani , linux-scsi@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH 2/2] scsi: qla2xxx: Fix error code in qla2x00_start_sp() Message-ID: <49866d28-4cfe-47b0-842b-78f110e61aab@moroto.mountain> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4aa0485e-766f-4b02-8d5d-c6781ea8f511@moroto.mountain> X-Mailer: git-send-email haha only kidding Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This should be negative -EAGAIN instead of positive. The callers treat non-zero error codes the same so it doesn't really impact runtime beyond some trivial differences to debug output. Fixes: 80676d054e5a ("scsi: qla2xxx: Fix session cleanup hang") Signed-off-by: Dan Carpenter --- drivers/scsi/qla2xxx/qla_iocb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index 9c70c4e973ee..730d8609276c 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c @@ -3912,7 +3912,7 @@ qla2x00_start_sp(srb_t *sp) pkt = __qla2x00_alloc_iocbs(sp->qpair, sp); if (!pkt) { - rval = EAGAIN; + rval = -EAGAIN; ql_log(ql_log_warn, vha, 0x700c, "qla2x00_alloc_iocbs failed.\n"); goto done;