Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1298893ybg; Thu, 11 Jun 2020 06:24:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUxHLb+TdPagKDUvajNb8IZE/wVV/vNiHvJpwTzRDL3G9rmRYGDP87ie8lk9LiSBsQLiXz X-Received: by 2002:a17:906:a889:: with SMTP id ha9mr8687320ejb.429.1591881875282; Thu, 11 Jun 2020 06:24:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591881875; cv=none; d=google.com; s=arc-20160816; b=UcsvD8mpxjCYn7oAaPI1duK2TAG8r0aTLYvRxKewaa7J+VqJIxxl9++Fbm5+Zh2h+j lcwY3HhRY7lEMLOG+z291YRGNC4uN+wldbnSbmX3K6KaHD8ujuMn42ZlAgtHWxzxnud2 uHweO4JAij6eIbJhid87pFODuUvDTSOPMZfdlgfFhs5MfPq7z+YcMHsvnx2BQJFAJqex pPy/BCJlxilBwNS4e8/Dhn4OPEy9iFMN98VnVfkN80jRNDQFnRMC4sida2l5/PVdqSeY /emcpYhs2/2qqe+IgXMwjHb2zTFpbII8N/XB3ovZX15mQIF+IByO+8qE7U2YLH3imWzL IxXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=40jMB08wz88s/sAmHyXFUu+hRD5Xk6h9Hi54Z4OJdzk=; b=XqVXxMjxPNDVMs+nndgEMMB5vlZUg9qGnpF5lgjVu0/kn66EbmTi/bD8bLhmCMZRNr WZvG64KqRx4/BGT2kCQWt5zc+EDpyGiq3pRICkbinmT3IUZvdaatIJcWK06c64e/uP6k eId6Lr658I2gT89SRyrxhDkof3RtXXqDbnKUetBwzbpiZg/Vg38LZu9y/o0Is+hFUaQ+ tiwTtVf0fueYXCFBOyafkoV/0M02QJJn2nQ4pCqxMBNIO7hlKEVnJ71H48yQIeL+sP1V DriOXX3Mr0Y9ujdhIpx2jRKJAVA+QzNlR2I8AeT3vhCBNNJkpcMj5kIs70VQe05LeGpu i7+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nmoxLQIC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds2si2277385ejc.114.2020.06.11.06.24.11; Thu, 11 Jun 2020 06:24:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nmoxLQIC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728162AbgFKNVp (ORCPT + 99 others); Thu, 11 Jun 2020 09:21:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:39844 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726249AbgFKNVo (ORCPT ); Thu, 11 Jun 2020 09:21:44 -0400 Received: from PC-kkoz.proceq.com (unknown [213.160.61.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1D7D520747; Thu, 11 Jun 2020 13:21:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591881703; bh=OBPMc7itq41nVZ9VUj3BHPffpSQ5D0xsnUCrEtNQCTw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nmoxLQICdTtxNJbc0hF3pdIDAq7WDR9cEkjY3uxws4uxjHSQHA87xquSpjp4kDRz7 APad7eBsR6z6gt2Qqks9gvePLoU6LFlzBwoUr9GBYce2FKNBPaBxTrJ9cCKN1dbCec UIY39La3e9X9N6dUhzlbpr17oLRpq5ueKaNtumVg= From: Krzysztof Kozlowski To: Vinod Koul , Dan Williams , Angelo Dureghello , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Robin Gong , Peng Ma , Fabio Estevam , Krzysztof Kozlowski , stable@vger.kernel.org Subject: [PATCH] dmaengine: mcf-edma: Fix NULL pointer exception in mcf_edma_tx_handler Date: Thu, 11 Jun 2020 15:21:05 +0200 Message-Id: <1591881665-25592-1-git-send-email-krzk@kernel.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1591877861-28156-2-git-send-email-krzk@kernel.org> References: <1591877861-28156-2-git-send-email-krzk@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Toradex Colibri VF50 (Vybrid VF5xx) with fsl-edma driver NULL pointer exception happens occasionally on serial output initiated by login timeout. This was reproduced only if kernel was built with significant debugging options and EDMA driver is used with serial console. Issue looks like a race condition between interrupt handler fsl_edma_tx_handler() (called as a result of fsl_edma_xfer_desc()) and terminating the transfer with fsl_edma_terminate_all(). The fsl_edma_tx_handler() handles interrupt for a transfer with already freed edesc and idle==true. The mcf-edma driver shares design and lot of code with fsl-edma. It looks like being affected by same problem. Fix this pattern the same way as fix for fsl-edma driver. Fixes: e7a3ff92eaf1 ("dmaengine: fsl-edma: add ColdFire mcf5441x edma support") Cc: Signed-off-by: Krzysztof Kozlowski --- Not tested on HW. --- drivers/dma/mcf-edma.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/dma/mcf-edma.c b/drivers/dma/mcf-edma.c index e15bd15a9ef6..e12b754e6398 100644 --- a/drivers/dma/mcf-edma.c +++ b/drivers/dma/mcf-edma.c @@ -35,6 +35,13 @@ static irqreturn_t mcf_edma_tx_handler(int irq, void *dev_id) mcf_chan = &mcf_edma->chans[ch]; spin_lock(&mcf_chan->vchan.lock); + + if (!mcf_chan->edesc) { + /* terminate_all called before */ + spin_unlock(&mcf_chan->vchan.lock); + continue; + } + if (!mcf_chan->edesc->iscyclic) { list_del(&mcf_chan->edesc->vdesc.node); vchan_cookie_complete(&mcf_chan->edesc->vdesc); -- 2.7.4