Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4592247ioa; Wed, 27 Apr 2022 07:07:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJrkBhKwTcAXRhCG8Iqj63Mlb//5QKgcCuvbqnsrNz+mXSYsKb/vWa0MY97Q6ldCjyVrg7 X-Received: by 2002:a62:b50d:0:b0:50d:43b8:f2cb with SMTP id y13-20020a62b50d000000b0050d43b8f2cbmr14940513pfe.13.1651068454156; Wed, 27 Apr 2022 07:07:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651068454; cv=none; d=google.com; s=arc-20160816; b=cFb29DklPgc5m9mUzmEsz5hcftpscaTrMYzu9Au+98T2kcO0VEapyLHFBA7+53wABY iVt1IIhN5UvzFuIlLzI5Lh5ewoSfMGSv694eMLkFaJ51vnjW1JtqKnAxIhofoaIMkBPa SO5ZbSQKlF5fK2anMi9XLoVuu/6xUMub8y7Ysl+Vm0QUxDXQCuvW4IOFJ3MH7bLTVIY1 SNY9ieqisMRxrkcNTCjKvgOpJLZY/KnW5un4MD1MsQU6mFde+Blgjx9Z+ZTDrkVMgQdX zXqDq/PMMIDSJOeqrVHV41mjo1lQ8vL9bnfrU2CKnsS2P9KpGy/++DsgYKYUAq5cqT+E zYrA== 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:dkim-signature; bh=HGr4ZsbPWAJgSC4/N8Ml+5pEamV/nRGhGHWpIvVEbm4=; b=X+w3rTirdwfOhCIzda/5R+U7xhUX27DEWWAfXOD3uzXHrhpfODxHwmgsxIPBm9CjNn h6SqWW50oMnVx/KlMBlObn36dkdneNEtI8N+5h0LEQ4drUV0oIqef9DmW6p5z+R+Cd6C jBKZv8wlbLhV4Ayz3NdwifeLiDxbg4KsvYOyfmOO+9scBSrpxiekn34vh2dnyZ+EDnlr +Zn904s8GAbtV9e6ITd6GR7pYgKtY3f31SXY2uxDQKCeO6rsbYJcsCfh3OGe7n9tNErs XB548hifR78+QnbLMKNkX8mMviG20Tr6yGDBGWLmynpBRrFfW2+mpimXBvhqJoww/mVp b3ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Tv2JjvEf; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id o24-20020a170902779800b0015425d91e51si1563923pll.618.2022.04.27.07.07.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 07:07:34 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Tv2JjvEf; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3A2CF4D605; Wed, 27 Apr 2022 06:37:18 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236474AbiD0NkU (ORCPT + 99 others); Wed, 27 Apr 2022 09:40:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236391AbiD0NkS (ORCPT ); Wed, 27 Apr 2022 09:40:18 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D9054D273; Wed, 27 Apr 2022 06:37:07 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id a1so1984453edt.3; Wed, 27 Apr 2022 06:37:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HGr4ZsbPWAJgSC4/N8Ml+5pEamV/nRGhGHWpIvVEbm4=; b=Tv2JjvEfv1hLVOzguuqbtyJLIbAC/QhCW0O+L15EfZdHBEF2t0keCi5ajjV/M9DGS5 4rVO+IfTupJyMKAN5h3l69l5ZZzEJZwZfPRcaG+tOCyeOGU9lpsKjt4ochVPrv2l8v2Y h7TvboXeXOIbHgbw2hUjNpk69hVla2UxYk1ag2KUmkZyB0GN7j4ltTzkBPQ5xp19Qn7w 2Fv4mApyKjGR8VycuhwICYrsnVajjQKi5XFoowXug+DEljpn0bJdMKaGc5MeN3gjCFfV NTuXFr+WZR1lU+CIvDJNnqUQSBueHkgPKbRATpGS8XDPMP6PmE8zefDr+GXsb36Rud4S h/cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HGr4ZsbPWAJgSC4/N8Ml+5pEamV/nRGhGHWpIvVEbm4=; b=RO5A/kqyOX1F0TTrDerwm9pyNJ8IoO/lmwRTFfbi4NMSpYHY/oJkDYCUN0GSkTEzAO RzOw2sc9dtxzm5GBz9h0FOFNjaytUDP8n3zUsVZbB4GS2plxVUTZh7nLRQhDuXsAa2eH gbqtNECy+MOcKVBPwGoGYc7tuWpHMDPqt8pYnGYQtLfDcxHh81o55Gxt2WeXul0BxEDG 439Wr9V2aI6xlW0bX5PATsJwkD74hhqWXU3UsVoln8jre1N15F6ZExiTHemRRji/q6ML ufF0EufCUI9T7EWz9SjSVaZ1dOkxL68SRrUa7uDLVQrT3rDjgD5hKSGJD1fNxcqcHcCG R9Ng== X-Gm-Message-State: AOAM530MnstW2vOdWXGY9mi1wm2DtHkHCSF2xqSVHhwLPcct02R36w8X 3nnsmvVtnrcWTA82UR1QTTo= X-Received: by 2002:a05:6402:2547:b0:426:1763:4c5b with SMTP id l7-20020a056402254700b0042617634c5bmr3048013edb.176.1651066626106; Wed, 27 Apr 2022 06:37:06 -0700 (PDT) Received: from linux.. (p5dd1ed70.dip0.t-ipconnect.de. [93.209.237.112]) by smtp.gmail.com with ESMTPSA id k20-20020a17090632d400b006f3a60598easm3394052ejk.129.2022.04.27.06.37.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 06:37:05 -0700 (PDT) From: Bean Huo To: jejb@linux.ibm.com, martin.petersen@oracle.com, john.garry@huawei.com, chenxiang66@hisilicon.com, bvanassche@acm.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: beanhuo@micron.com Subject: [PATCH v1] scsi: libsas: Fix array-bounds warnings Date: Wed, 27 Apr 2022 15:36:57 +0200 Message-Id: <20220427133657.55241-1-huobean@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE autolearn=no 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 From: Bean Huo Use the latest GCC will show below array-bounds warning: drivers/scsi/libsas/sas_expander.c:1697:39: warning: array subscript ‘struct smp_resp[0]’ is partly outside array bounds of ‘unsigned char[56]’ [-Warray-bounds] ... drivers/scsi/libsas/sas_expander.c:1781:20: warning: array subscript ‘struct smp_resp[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds] ... rivers/scsi/libsas/sas_expander.c:1786:39: warning: array subscript ‘struct smp_resp[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds] ... drivers/scsi/libsas/sas_expander.c:476:35: warning: array subscript ‘struct smp_resp[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds] ... drivers/scsi/libsas/sas_expander.c:479:38: warning: array subscript ‘struct smp_resp[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Warray-bounds] This patch aims to fix these warnings by directly using struct sizes instead of macro definitions. Signed-off-by: Bean Huo --- drivers/scsi/libsas/sas_expander.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c index 260e735d06fa..ac6d9be358c5 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c @@ -457,7 +457,7 @@ static int sas_ex_general(struct domain_device *dev) if (!rg_req) return -ENOMEM; - rg_resp = alloc_smp_resp(RG_RESP_SIZE); + rg_resp = alloc_smp_resp(sizeof(struct smp_resp)); if (!rg_resp) { kfree(rg_req); return -ENOMEM; @@ -1688,7 +1688,7 @@ static int sas_get_phy_change_count(struct domain_device *dev, int res; struct smp_resp *disc_resp; - disc_resp = alloc_smp_resp(DISCOVER_RESP_SIZE); + disc_resp = alloc_smp_resp(sizeof(struct smp_resp)); if (!disc_resp) return -ENOMEM; @@ -1766,7 +1766,7 @@ static int sas_get_ex_change_count(struct domain_device *dev, int *ecc) if (!rg_req) return -ENOMEM; - rg_resp = alloc_smp_resp(RG_RESP_SIZE); + rg_resp = alloc_smp_resp(sizeof(struct smp_resp)); if (!rg_resp) { kfree(rg_req); return -ENOMEM; -- 2.34.1