From patchwork Wed Jan 20 09:57:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 12031937 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8521C433E6 for ; Wed, 20 Jan 2021 10:45:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E2D32333C for ; Wed, 20 Jan 2021 10:45:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733018AbhATKdg (ORCPT ); Wed, 20 Jan 2021 05:33:36 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:40058 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726634AbhATJ64 (ORCPT ); Wed, 20 Jan 2021 04:58:56 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10K9mWD3191390; Wed, 20 Jan 2021 09:58:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type : in-reply-to; s=corp-2020-01-29; bh=5uRrrgWyIgytuqolSTvGY83GZ1TKvBn02elPXkSu0ZY=; b=T4OuFbTdmt7dThjjIReLVYcxAC9iWS7Q8JVpLQwbrx5lbgI1zGSstFzYw1hhPV7ZDBd5 wn/JdKw7POBb/sNblU4MH8FUTvYf5iFBuL6MbS9aiFJxkTrJdpCbX/iFpplABLbYiI/r BvBSuR0O3U8CQGZID1QJj33LXSNU5/JEQ97N6LhTC4VKNSGPy6Cv+LGucglRdttAYn1O /bRu1cWAueNhrctBQKmMIvmbWAiDQO1OUBaHwTSiA9d8I83vEH+w8aaX1INHZEJdVrey 8gBkwgRjgG6H6OErB5+MtVGwus22CBlBUw9wT5cBY2nVkqXPZZXB8zInslr5bH/cFBKt uA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2130.oracle.com with ESMTP id 3668qr9q62-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Jan 2021 09:58:07 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10K9sceA125867; Wed, 20 Jan 2021 09:58:06 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 3668quxvxr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Jan 2021 09:58:06 +0000 Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 10K9w4BD019202; Wed, 20 Jan 2021 09:58:04 GMT Received: from mwanda (/10.175.34.136) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 20 Jan 2021 01:58:03 -0800 Date: Wed, 20 Jan 2021 12:57:55 +0300 From: Dan Carpenter To: Andy Gross , Dmitry Baryshkov Cc: Bjorn Andersson , Stephen Boyd , Sai Prakash Ranjan , Douglas Anderson , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] soc: qcom: socinfo: Fix an off by one in qcom_show_pmic_model() Message-ID: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210118113651.71955-1-colin.king@canonical.com> X-Mailer: git-send-email haha only kidding X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9869 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 suspectscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101200056 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9869 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 suspectscore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 spamscore=0 phishscore=0 priorityscore=1501 impostorscore=0 malwarescore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101200055 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org These need to be < ARRAY_SIZE() instead of <= ARRAY_SIZE() to prevent accessing one element beyond the end of the array. Fixes: e9247e2ce577 ("soc: qcom: socinfo: fix printing of pmic_model") Signed-off-by: Dan Carpenter Reviewed-by: Douglas Anderson Acked-by: Dmitry Baryshkov Reviewed-by: Stephen Boyd --- drivers/soc/qcom/socinfo.c | 2 +- 1 file changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c index a985ed064669..5b4ad24a022b 100644 --- a/drivers/soc/qcom/socinfo.c +++ b/drivers/soc/qcom/socinfo.c @@ -309,7 +309,7 @@ static int qcom_show_pmic_model(struct seq_file *seq, void *p) if (model < 0) return -EINVAL; - if (model <= ARRAY_SIZE(pmic_models) && pmic_models[model]) + if (model < ARRAY_SIZE(pmic_models) && pmic_models[model]) seq_printf(seq, "%s\n", pmic_models[model]); else seq_printf(seq, "unknown (%d)\n", model);