From patchwork Fri Apr 12 08:25:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 13627159 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 96AB4C00A94 for ; Fri, 12 Apr 2024 08:25:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:Cc:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=fO/38J/z3P0bUXRtTyVEpcVmPuDOzfqVQg31wPRxKVs=; b=mgel/K0VgGiyXk xAw9sxAy+rPjaFSyb5mJ401Wb1gfmj40fJY6unsxLvW7fuLFnnGvd99RescbesR0rgi6tgtCXLX1R /eroRaP3kj7DhdxMJqADpnCl0XFO3jUClumq5w6Gs5E/x0Hp/Ak2EJ46ml9zYzAKWVyDSzqYLAH45 lNyGa1ObIFagrBNGgmcABR1G7O9//G7ZuKKgtWbiB1uegKdpcwkX4h2MoVXQixxQpiKsOeMbqVtfF fxm2Zoal0f0kEdrjCRid6G5mEyqaH5j0P/mCq8Egh7n3+ZP6Ofi+1e8AhWvjiaxfZsPEcdqRIIOep seK4VeHo+4v497ldPDSw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvCEF-0000000G4E4-0fW8; Fri, 12 Apr 2024 08:25:47 +0000 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvCEC-0000000G4DY-2Tuf for linux-arm-kernel@lists.infradead.org; Fri, 12 Apr 2024 08:25:45 +0000 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a51b008b3aeso70192566b.3 for ; Fri, 12 Apr 2024 01:25:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712910342; x=1713515142; darn=lists.infradead.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=zBk3IkdFTVmum+vYtVeAJMby59eq87hfD5TBghPTWMM=; b=r+eAgDJ06HXKY8wHK8+tgf8UCeJdJbA3K9KJzsVMzVazPkJxna6Zj/rJ6M2kh0x7+6 tY0ehnm1X03Kr3SV1isz4zLh//YRUynePFCuMTcErGpqxjKL3MhtcXhzEVq5kvQd1awz 2uP2DPLkEOs0arsRYi3jkKjh2WqhmtvQpNgQaAX2OCNiyAhcSsxldEiTaG7pUPEkVuy3 aqwqHvnlq938fiuZgqxewckKuDjk38Hs5R/lePZzs04MlFWBFqJuIIZ2elgnKr0QvWec WDP7ecnsyV4Rx1Pf51rPmNbjaT632TE2hsNOmPGgfjathohrOh08Zn15OESmHOoGW4kN 9z8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712910342; x=1713515142; 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=zBk3IkdFTVmum+vYtVeAJMby59eq87hfD5TBghPTWMM=; b=PAJ7/g2NI/kZrVft0KT3tYEJmZlUaCMRGuHw1IbXIRi5X/dp2gRPTD4yWUOgLfyY0F myabZhhFYGEs+zjSBt542EqG6ejZ7FHZhHuSAOyzDS6Rgblg8vxEJG7qHkw9mGCXz+x9 XWwbmTeIL4uXUb5YJx5kWgFTi3SFGQDZYvQ2M69a9d5oaXytU9aA1rqmUlZJkJgIpVbO i3IOjx5wUojYrVbGFiJ54g6rqyfm0jMXvD02S4Od4cTvOMJ7VPJs1tdCyJJiPl/SeEz0 1rvN/tvyX+CON7pDsgIJ8tUndM+KNqYVkDpDPvdj2zCnY50fwLOdBTMgZGHOW3xm/xi1 GzNg== X-Forwarded-Encrypted: i=1; AJvYcCUJn7dlIcVJ9ZH1wSc+OaG4taS408En3cnAbYjbWj8mQmpfqw+MEej7N0RFxLGFN40zWY8bB4divmUOSA+EMUNAqgueBKY+NLPppYJQayaoN8eCbZg= X-Gm-Message-State: AOJu0Yz47kPmrsLTSs8W9OmgJ3UPFYnnYykTNwzzq8usP/tjYgKpm2iB SVa5Tx79/asg8OTQjhkwB5v+PZWFHbvWZQYkBSUMOXtzJCSItCsKi6eBJ6XlrCk= X-Google-Smtp-Source: AGHT+IE00wDPrRr8eIax00TpINor2PbGdsjSZ8kU77JYzzDd3jq7whb6zK+VFuCJsGHEYumc624Pkw== X-Received: by 2002:a17:906:4f06:b0:a51:e351:9ad4 with SMTP id t6-20020a1709064f0600b00a51e3519ad4mr1518672eju.9.1712910341629; Fri, 12 Apr 2024 01:25:41 -0700 (PDT) Received: from localhost ([102.222.70.76]) by smtp.gmail.com with ESMTPSA id go36-20020a1709070da400b00a51fea47897sm1546872ejc.214.2024.04.12.01.25.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 01:25:41 -0700 (PDT) Date: Fri, 12 Apr 2024 11:25:37 +0300 From: Dan Carpenter To: Gatien Chevallier Cc: Maxime Coquelin , Alexandre Torgue , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] bus: stm32_firewall: fix off by one in stm32_firewall_get_firewall() Message-ID: <17dce071-21ef-49f5-be45-f93bbf3642ec@moroto.mountain> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240412_012544_662629_5543B324 X-CRM114-Status: GOOD ( 12.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The "nb_firewall" variable is the number of elements in the firewall[] array, which is allocated in stm32_firewall_populate_bus(). So change this > comparison to >= to prevent an out of bound access. Fixes: 5c9668cfc6d7 ("firewall: introduce stm32_firewall framework") Signed-off-by: Dan Carpenter Reviewed-by: Gatien Chevallier --- drivers/bus/stm32_firewall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/bus/stm32_firewall.c b/drivers/bus/stm32_firewall.c index decb79449047..2fc9761dadec 100644 --- a/drivers/bus/stm32_firewall.c +++ b/drivers/bus/stm32_firewall.c @@ -53,7 +53,7 @@ int stm32_firewall_get_firewall(struct device_node *np, struct stm32_firewall *f return err; } - if (j > nb_firewall) { + if (j >= nb_firewall) { pr_err("Too many firewall controllers"); of_node_put(provider); return -EINVAL;