From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f46.google.com (mail-oo1-f46.google.com [209.85.161.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C9D23AD535 for ; Thu, 9 Jul 2026 10:27:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783592841; cv=none; b=jYMIsTab9M5TIDrt0nkE00H3aDeDN9JbF6shDuJT/EU4bf5KXojBHa86Z2mG6eO84nwLveQgHa+MzOn0SysocIcAYrqNJ55eUgLeOHN5lt6QsdIHz2ZlAds7Dc3dQzQjk/PDYi77Ig0xExpFKlpA/0ii+/PPg7bBFiX+VrSeop0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783592841; c=relaxed/simple; bh=L2WCr6taxGkTOVHzUf3RYCQ2nUSH6l8pW3+moY7GGhw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=c6ogvnI0cp7gugqUkelosdd6pAMm6ZYzm/xvtX9pSsL93rt9h49oIVjr/L0mCKOt4HyisUO4QWl0xNTD5dzzGnIDF5pg54rSWdD05dRrswejsODNuCoeNxT2ARVkl59mkxoDMEBZ4K6E/PbfRz9/m+1dWkNF/JNs47TWN7pQkD4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XMmKUPyL; arc=none smtp.client-ip=209.85.161.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XMmKUPyL" Received: by mail-oo1-f46.google.com with SMTP id 006d021491bc7-69e9b037d82so1285126eaf.2 for ; Thu, 09 Jul 2026 03:27:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783592839; x=1784197639; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=yTHA/HAGmx+6vLyILbr+Ji6px3cTIRCKaDC8NslzL3E=; b=XMmKUPyL5cepxfvC1sytDE50rvwWz0WpmOPoZt0EQZc5uHqin6aH5olO9ekZzFKeZm kKgr3UHr2zIC+oTZNiGV+UbfvmI+yEfvz1JesK5Gn4j3wHGVvb5Hik3UxL8/P+tSd5hB 5/Mhz6p0ZL6KMb1d0A6aDLqF7SnxQgD67P8eD8b6BMrqWZm3w1r3fZIaLPLlu1+WnHHJ QKnZuSfJrduak1B8fs5asfugeS7eOFsK0bqAtjLMiL+AOG4wHLY6KjoeS7c5+BJpBMLa khwlcdMeDphFSyhbQKNi57VpPi8A/FamsuhqKZW0Yg+D+dWjNmqlY/Jfx4DmWXfL8D36 Y85A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783592839; x=1784197639; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=yTHA/HAGmx+6vLyILbr+Ji6px3cTIRCKaDC8NslzL3E=; b=EEcTCCvpFIueRhGbSlPO8haWwl90Xn9ivJWkMtGKiTWkryEo8zLHy/RV/cr6D8Wu9h BZ4dZ1SH50gNBYfJJW1l820G+QTWDXhi55SWK35kQGbUYrrAMBnl8mD6jehveqqCZOxA +fPfbe5ZdJmo0ctcG/LrPkTSkyyzIq+BpWNobx9WuU3fpLQ2nFUSsKp1klBVfwLzbADO RMTaLbAX2I2bz2huN3GdqjiFd+IKNtD6W1/ynLKFcbnfpfNMlyA1cFONAtMHGVhqoA5z eQtwfEtAJS5METEWsgTPhn1Yy+SYnB3x74/FU2j5lf5XmOVNpqIUMhSewsR/aLYJ/sh5 VX3g== X-Forwarded-Encrypted: i=1; AFNElJ9lfrRyS3+b7zuWmgZbRfB+wPfxSbEXTYQnPHhnI0qXvfQVnKov1tWzHtu/ZHyokpgbhhSx8xflyTaAijA=@vger.kernel.org X-Gm-Message-State: AOJu0YwdygqT6D5ubM1LeUvp2gvf0ycS0wzIkvJKKv+Eij/PXK8eb0sx Bt8LnNVfNiiQCJNrv8eUwv5VzXTlm43WejX6C0nfJSzoCjFe/rqib8ci X-Gm-Gg: AfdE7ckhystgJ5+B1DS6jTaU2EGybkescfVRDEB4a1Bf9jnG8CZEWXQ2zRUma/lf3jk B86S8vbAZnuab2sh4lLMf70zaZJ32EKrQMQjkAAISu4t1UI7umr7F+cN2KnNgw06dsI8mKAqTbR HT5xFdjP1DDjsmrAt44QlTPuHuHJiuPO56fqBPyZJ0cPnXcyhey72YZuwwtXpZ52nykDXBXEq1V aV+whYP1uYDLhp+5Ky5F4NbRwZJniieZf4nkLN6KclJeyZD8pXSfam3ejDZOAFTXRSyoKDL49wL jU7Pm+cARJ0IMuE0I6Ej2Wx6Z6IcuFQifH6tpTLgv7/PT9EfOxwpcpVIAWWMi940ngrgaSw+tT6 i2Uv767VPnXnhN8e2CIDQmXKEcWioz8MQySCLzA6zl0xhXwImpK42YeVOrmfkYqyDt/LGKpY8Sr aMr/sx4m9TvCxZ48U= X-Received: by 2002:a05:6820:189a:b0:6a3:15c3:e60d with SMTP id 006d021491bc7-6a36da65eaamr5053920eaf.71.1783592839034; Thu, 09 Jul 2026 03:27:19 -0700 (PDT) Received: from localhost ([74.80.182.70]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-6a37b58f98csm1338565eaf.13.2026.07.09.03.27.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2026 03:27:17 -0700 (PDT) Date: Thu, 9 Jul 2026 13:27:11 +0300 From: Dan Carpenter To: christian.taedcke@weidmueller.com Cc: Vinod Koul , Frank Li , christian.taedcke-oss@weidmueller.com, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] dmaengine: nbpfaxi: Fix setting channel irqs in probe() Message-ID: References: <20260702-upstreaming-nbpfaxi-v1-v1-1-fd8ea8830cea@weidmueller.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260702-upstreaming-nbpfaxi-v1-v1-1-fd8ea8830cea@weidmueller.com> On Thu, Jul 02, 2026 at 03:43:29PM +0200, Christian Taedcke via B4 Relay wrote: > From: Christian Taedcke > > When one irq is used for errors and each channel gets a dedicated irq, > the total number of irqs is num_channels + 1. If the error irq is not > the last entry in irqbuf[] but an earlier one, the loop assigning > per-channel irqs terminates one iteration too early and the last > channel is left without an irq. > > Iterate over all collected irqs instead of num_channels so the > error-irq skip does not shorten the effective channel count. > > Fixes: 188c6ba1dd92 ("dmaengine: nbpfaxi: Fix memory corruption in probe()") > Cc: stable@vger.kernel.org > Signed-off-by: Christian Taedcke > --- > drivers/dma/nbpfaxi.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/dma/nbpfaxi.c b/drivers/dma/nbpfaxi.c > index 05d7321629cc..74ff7bd979e2 100644 > --- a/drivers/dma/nbpfaxi.c > +++ b/drivers/dma/nbpfaxi.c > @@ -1374,7 +1374,7 @@ static int nbpf_probe(struct platform_device *pdev) > if (irqs == num_channels + 1) { > struct nbpf_channel *chan; > > - for (i = 0, chan = nbpf->chan; i < num_channels; > + for (i = 0, chan = nbpf->chan; i < irqs; > i++, chan++) { > /* Skip the error IRQ */ > if (irqbuf[i] == eirq) > > --- Ah. Thanks. I feel like it would make sense to change the other condition as well to: - for (i = 0, chan = nbpf->chan; i < num_channels; + for (i = 0, chan = nbpf->chan; i < irqs; i++, chan++) { /* Skip the error IRQ */ if (irqbuf[i] == eirq) i++; - if (i >= ARRAY_SIZE(irqbuf)) + if (i >= num_channels) return -EINVAL; chan->irq = irqbuf[i]; If we don't find the error IRQ then it would be possible to go out of bounds of the chan->irq. It's not likely to happen in real life but it sort of makes the code make more sense? regards, dan carpenter