From patchwork Mon Sep 20 09:56:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 514303 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1890804jao; Mon, 20 Sep 2021 02:56:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyld4jOWeSikYQupQobXpr7t0tSYKP1z2cEGnvzyuDhbuC0gaGfrERg6wLeLfsCgFLY6Ysg X-Received: by 2002:a17:906:c055:: with SMTP id bm21mr27409637ejb.350.1632131794983; Mon, 20 Sep 2021 02:56:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632131794; cv=none; d=google.com; s=arc-20160816; b=VQCIeQdyC289wasMk8VkKiRgu/3FInWyGdSds+D8OfZYutXSzIEZWmATNUylo4EP0c 1VkPJuGuAap5vWUFoHpvQKOJRvWYjRzK7YrW+oS7x5Gn7hIZTAXNk/9JqO06XcR7Y7YP QlJWb9JDh1Bkh3hUqt4SNn3vQLLUtydDUhuykiXzBFjXNd1oQwJ/E/IoMtc/iyffa3L7 BqpSs/pix5OcZbnR1+JTUQBgXzPd+H3sDreof+HezU5b4ZLzVWfSiyCuxN8TJkgucj7K rrOseETfGzzKkeFXoRFcyBCn12QhRUGGBsD2iNGhpZV/gRz+7B7LYN8m1I9CNApecuGs +muQ== 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=V85cSZxw6oip5/5Pr3N7Gf+TH91ALdlNvz9IoPHd8YY=; b=oBClRhtbRU0E+jmtYnGcxG1UuIB32ysEbecTVRQp9WY+3LvBa31RqFJvrNuGCe8EuV p9fdizUZHJXGvhhyv7RsjzEPk/iuk9gx0gR6i8GyEHmy3mFrgcCtryDV7JdxW9wa2Yg5 5vYe2nlXjLwav+966881UDrpmlO1qzsmWktmeQdx3my2Owi9U9W7Xrr+5R7Ds0fEt9o5 xh0gZlBBouoYKm/edDjttLOu8mBHbSWcixWrpf351B0elz44FnJboqJlE6zbqtDatKOK SKXCNCx/tg7INBjnNntOctx0/4b6161MpSlrplhUukjAVmWiXFkc5oVupmxNnEmXon/u rOmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qd1DbWTk; spf=pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o9si341852edi.274.2021.09.20.02.56.34 for ; Mon, 20 Sep 2021 02:56:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-scsi-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=@kernel.org header.s=k20201202 header.b=qd1DbWTk; spf=pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231631AbhITJ6A (ORCPT ); Mon, 20 Sep 2021 05:58:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:40622 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229650AbhITJ57 (ORCPT ); Mon, 20 Sep 2021 05:57:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 78ABD60F9D; Mon, 20 Sep 2021 09:56:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632131793; bh=/JPK7Aa+16V2XfmQjabOyz7J9/sDWLciDQDg3Rabzw8=; h=From:To:Cc:Subject:Date:From; b=qd1DbWTkZetXA19rFyBSAErgu9uP23Hz56h5qq07iAYfhxzhWsEN8yd/CUQNjzQV1 LQ/b3j+FVIDDVb6YeiKJNyFWvGxrV7TlQ9ClmuhHmjckK/DF2R4zoGAMUtel2WkQxs AyDmsEkMIdQXmXpGsHiNmfBqeeGEwx60yBLqKNWsAdAojANXCdN5tnY+Fpvu7I/Opj u6nUc6pxl3yBHnJZ62lVFWmgtMxVwNhl5QCEaTIabj4IT3sUyLUh12T8DgFW2QP9eU aHcH3b/YxPjyD5UNqcB3gOvFTvfb+KN5ZYHZHJFE0W0ifuQ4A1arbFUFRhYqUyjjRh NzVYa/wMtwwvg== From: Arnd Bergmann To: James Smart , Dick Kennedy , "James E.J. Bottomley" , "Martin K. Petersen" , Arnd Bergmann , Justin Tee Cc: Lee Jones , Gaurav Srivastava , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] scsi: lpfc: Fix gcc -Wstringop-overread warning, again Date: Mon, 20 Sep 2021 11:56:22 +0200 Message-Id: <20210920095628.1191676-1-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Arnd Bergmann I fixed a stringop-overread warning earlier this year, now a second copy of the original code was added and the warning came back: drivers/scsi/lpfc/lpfc_attr.c: In function 'lpfc_cmf_info_show': drivers/scsi/lpfc/lpfc_attr.c:289:25: error: 'strnlen' specified bound 4095 exceeds source size 24 [-Werror=stringop-overread] 289 | strnlen(LPFC_INFO_MORE_STR, PAGE_SIZE - 1), | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fix it the same way as the other copy. Fixes: ada48ba70f6b ("scsi: lpfc: Fix gcc -Wstringop-overread warning") Fixes: 74a7baa2a3ee ("scsi: lpfc: Add cmf_info sysfs entry") Signed-off-by: Arnd Bergmann --- drivers/scsi/lpfc/lpfc_attr.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) -- 2.29.2 Reviewed-by: James Smart diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c index b35bf70a8c0d..ca0433e28ac3 100644 --- a/drivers/scsi/lpfc/lpfc_attr.c +++ b/drivers/scsi/lpfc/lpfc_attr.c @@ -285,11 +285,8 @@ lpfc_cmf_info_show(struct device *dev, struct device_attribute *attr, "6312 Catching potential buffer " "overflow > PAGE_SIZE = %lu bytes\n", PAGE_SIZE); - strscpy(buf + PAGE_SIZE - 1 - - strnlen(LPFC_INFO_MORE_STR, PAGE_SIZE - 1), - LPFC_INFO_MORE_STR, - strnlen(LPFC_INFO_MORE_STR, PAGE_SIZE - 1) - + 1); + strscpy(buf + PAGE_SIZE - 1 - sizeof(LPFC_INFO_MORE_STR), + LPFC_INFO_MORE_STR, sizeof(LPFC_INFO_MORE_STR) + 1); } return len; }