From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 54C4B2356B9; Fri, 29 Aug 2025 10:02:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756461738; cv=none; b=R0aBR6/fbAx42QGCXexZDuBGFHvQKOZnaK1vZsOZJ2DRvenJyGOP8RfeiVXjnubkX1WfdHRcvukCPRByAlpGtpuLH974AkSCL1mMtzrFHjCZR/H9AOA1BEusI74iqBpTIZk/RfbXHp7vD+Gmx4r31AU8HZ9bS82gBHmbuvXfr8I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756461738; c=relaxed/simple; bh=DrQaeHhNiQJS79bx/Swtonuixek3OXzAvPbA8YKO6gk=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=HGahWHWTU9fwaBvVhTfHM8mQCpBV0rMQ/6BU510AeaGBdKlzOnnIk9sNmkLZfRn/U9BQx5gGZm1g2vmlVoLeVKTWTd9QzE9FXvuX2lCHcPgExNAnN1gH/Q3qEooTky0uaqaKwGcdLgF7ugZk2bETxdJrIwnsdEorr8Xu9RmtIKo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 10BF51758; Fri, 29 Aug 2025 03:02:07 -0700 (PDT) Received: from [10.57.2.173] (unknown [10.57.2.173]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id ACCDD3F694; Fri, 29 Aug 2025 03:02:13 -0700 (PDT) Message-ID: <82cf913c-f050-4325-ac5b-7efd0634d8ff@arm.com> Date: Fri, 29 Aug 2025 11:02:06 +0100 Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 03/14] dmaengine: dma350: Check vchan_next_desc() return value To: Jisheng Zhang , Vinod Koul , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20250823154009.25992-1-jszhang@kernel.org> <20250823154009.25992-4-jszhang@kernel.org> From: Robin Murphy Content-Language: en-GB In-Reply-To: <20250823154009.25992-4-jszhang@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2025-08-23 4:39 pm, Jisheng Zhang wrote: > vchan_next_desc() may return NULL, check its return value. IIRC it's important that dch->desc gets set to NULL in that case, otherwise things can go wonky after a completion interrupt - i.e. the current code *is* using the return value both ways, just the sneaky thing is that it does actually depend on "vd" being the first member of d350_desc to do it concisely, sorry I didn't document that. Thanks, Robin. > Signed-off-by: Jisheng Zhang > --- > drivers/dma/arm-dma350.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/dma/arm-dma350.c b/drivers/dma/arm-dma350.c > index 24cbadc5f076..96350d15ed85 100644 > --- a/drivers/dma/arm-dma350.c > +++ b/drivers/dma/arm-dma350.c > @@ -399,11 +399,14 @@ static enum dma_status d350_tx_status(struct dma_chan *chan, dma_cookie_t cookie > static void d350_start_next(struct d350_chan *dch) > { > u32 hdr, *reg; > + struct virt_dma_desc *vd; > > - dch->desc = to_d350_desc(vchan_next_desc(&dch->vc)); > - if (!dch->desc) > + vd = vchan_next_desc(&dch->vc); > + if (!vd) > return; > > + dch->desc = to_d350_desc(vd); > + > list_del(&dch->desc->vd.node); > dch->status = DMA_IN_PROGRESS; > dch->cookie = dch->desc->vd.tx.cookie;