From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5B71841EAF; Thu, 16 Mar 2023 10:42:17 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4210142C54; Thu, 16 Mar 2023 10:42:17 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 930D240FDF for ; Thu, 16 Mar 2023 10:42:15 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32G7kVhP005837 for ; Thu, 16 Mar 2023 02:42:14 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=cdN4vPOTdF88W+wdqU4qrN9jPjPSNpGLp4zSYsLse/k=; b=V8zdoDn2BtB8sgevM0Aowe+AclfkVLiK/BA2DYu/xEEPbY1J+DkjlR0T3ymqDZ5l/XFE jE53M+BNPr45tuLz1mjcasZL1a/qry3wvLvre6M5L2JIugxn6XLVvcklnkgKKbaEcIdr S10fqfjC+I28uE93tTHiUEMapZds+hYlMgQpzyFf1adpd6qOOJSJ60XcSf8IcMgH9M07 +yAj6LaXvHgaKVU+mufPLKvFjSsYKFZPqzZFaEYBYKjHD9vMsQyyoFccFQdh+YNKOMwD yQEt31G7zIDTYD1XxHZ7zX3GIlB9hLwj9RMxmrfm+h/OeEw5qvynhG4xWv8Gf3hdj8nk 2g== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3pbxq2rh1e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 16 Mar 2023 02:42:14 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 16 Mar 2023 02:42:12 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.42 via Frontend Transport; Thu, 16 Mar 2023 02:42:12 -0700 Received: from cavium-DT10.. (unknown [10.28.34.39]) by maili.marvell.com (Postfix) with ESMTP id F27253F703F; Thu, 16 Mar 2023 02:42:11 -0700 (PDT) From: Tomasz Duszynski To: , Tomasz Duszynski Subject: [PATCH 1/2] bus/platform: fix resource names iteration Date: Thu, 16 Mar 2023 10:41:32 +0100 Message-ID: <20230316094133.237641-1-tduszynski@marvell.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: 5pzQk2GCFsyMRa3OOYEfX6gWrcAyA_Nx X-Proofpoint-ORIG-GUID: 5pzQk2GCFsyMRa3OOYEfX6gWrcAyA_Nx X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-16_06,2023-03-15_01,2023-02-09_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Fix stop condition and make sure we have some sentinel at the end of buffer to make sure loop can properly terminate. Coverity issue: 383661 Fixes: 17c839f74da3 ("bus: add platform bus") Signed-off-by: Tomasz Duszynski --- drivers/bus/platform/platform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/bus/platform/platform.c b/drivers/bus/platform/platform.c index 536d9524c6..a2faacdf18 100644 --- a/drivers/bus/platform/platform.c +++ b/drivers/bus/platform/platform.c @@ -249,11 +249,11 @@ of_resource_name(const char *dev_name, int index) char *name; snprintf(path, sizeof(path), PLATFORM_BUS_DEVICES_PATH "/%s/of_node/reg-names", dev_name); - ret = read_sysfs_string(path, buf, sizeof(buf)); + ret = read_sysfs_string(path, buf, sizeof(buf) - 1); if (ret) return NULL; - for (name = buf; name; name += strlen(name) + 1) { + for (name = buf; *name != 0; name += strlen(name) + 1) { if (num++ != index) continue; return strdup(name); -- 2.34.1