Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4438805ioa; Wed, 27 Apr 2022 04:02:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxF1nrVHzkTy2TyfgODWa+dqlO40SHo4gXA+XbTKEapl8tWcymesun7uTEQfjeM8vCn/uPR X-Received: by 2002:a05:6e02:18ce:b0:2cc:59c9:e35e with SMTP id s14-20020a056e0218ce00b002cc59c9e35emr11553601ilu.217.1651057328892; Wed, 27 Apr 2022 04:02:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651057328; cv=none; d=google.com; s=arc-20160816; b=gCLzeZddIZdewd8+rLWxl6ELz74L1474N/F0pAf0sIe5H7OP8qt6JnSSlJy5zCpeCf 7sEbGS3rGCONikFJyDAe9gdzSyDDz00yYMauFkIxhrQXfPN26YgWybdTtAEbCo2lHzdA wD3GMIdLA677aEUm4TUQsoj88VQfrqAfOa88Fb156NCl9Mnr5gQCGSm0ujmRs6vll14j 4HiCQqo+w6eHLP4oPeFtAqaQv7wTz18GwujRMzFE8IzaKkN0vkLoh141ZpvOV4Ri/WNK gs1e6zAIX4v1LLZY1E8nH0vu5a1IQAUrBjA2GdiGV+OY2t/pjaY3BjqAHkMIDmwuZh1K kiCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/0EwanxJ2mz2ceIHLdspz4wyiXW88Nc5j1OUdWZE1BM=; b=Dk6Ej6AnfVfxxhRLVGT/T1yGKvjbr0ULpOX48LyrKV+Ue9h1ElKBkhW7ZLuwZg+kxt TI6dKX6wgtrVUwr4L9TYA6wS7PxE9CJ8nZY7UxH507tyVUyL9NiUgnCfiZilDXmwwEWB DPHRgoUx3s7akcpfK4HGWsMOSKIYwq2CbhjC5Kx/xpc6vUmREhaqZYDzZNpgrjblMeUq 0Pmt6a+rE1jz4RW8DIw75nCLTwh/er9WY/g3Ega9r48/20IxMnGyxD6xgniVeejs7MlJ JhcraE22EK2RHMFWlWooiX+wAJw1I0eHyskVCnGBfkBDadG3CqcPbciUo+GlSAgBdjaX SedA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WNzq6ozR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id t41-20020a05663834a900b0032af20204e2si553828jal.51.2022.04.27.04.02.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 04:02:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WNzq6ozR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 254B4447666; Wed, 27 Apr 2022 03:11:01 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238454AbiDZJUs (ORCPT + 99 others); Tue, 26 Apr 2022 05:20:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345602AbiDZI51 (ORCPT ); Tue, 26 Apr 2022 04:57:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B84384EC6; Tue, 26 Apr 2022 01:42:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BBCF660A67; Tue, 26 Apr 2022 08:42:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C29CFC385A0; Tue, 26 Apr 2022 08:42:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650962521; bh=+kalJFicQos3OPzHJvD22NxkzItAti/SDX2f8dJuBmw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WNzq6ozR+EZtz59Dbtwqf493lVRfwg8lXRA0UWyTcrLeF9fzumMWiKsR6veGz1/R+ uXhY+ea1SqHZyaS4jAb6xpW72l4tS5xaVVSUmhDD6edjMerDv3XzzmEXtqXaz5F83t TWVwCODU8K2MdpZF8ZHraM7IUI4u4f29/9tI79m0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiaomeng Tong , Vinod Koul Subject: [PATCH 5.15 084/124] dma: at_xdmac: fix a missing check on list iterator Date: Tue, 26 Apr 2022 10:21:25 +0200 Message-Id: <20220426081749.689618472@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220426081747.286685339@linuxfoundation.org> References: <20220426081747.286685339@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiaomeng Tong commit 206680c4e46b62fd8909385e0874a36952595b85 upstream. The bug is here: __func__, desc, &desc->tx_dma_desc.phys, ret, cookie, residue); The list iterator 'desc' will point to a bogus position containing HEAD if the list is empty or no element is found. To avoid dev_dbg() prints a invalid address, use a new variable 'iter' as the list iterator, while use the origin variable 'desc' as a dedicated pointer to point to the found element. Cc: stable@vger.kernel.org Fixes: 82e2424635f4c ("dmaengine: xdmac: fix print warning on dma_addr_t variable") Signed-off-by: Xiaomeng Tong Link: https://lore.kernel.org/r/20220327061154.4867-1-xiam0nd.tong@gmail.com Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman --- drivers/dma/at_xdmac.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) --- a/drivers/dma/at_xdmac.c +++ b/drivers/dma/at_xdmac.c @@ -1450,7 +1450,7 @@ at_xdmac_tx_status(struct dma_chan *chan { struct at_xdmac_chan *atchan = to_at_xdmac_chan(chan); struct at_xdmac *atxdmac = to_at_xdmac(atchan->chan.device); - struct at_xdmac_desc *desc, *_desc; + struct at_xdmac_desc *desc, *_desc, *iter; struct list_head *descs_list; enum dma_status ret; int residue, retry; @@ -1565,11 +1565,13 @@ at_xdmac_tx_status(struct dma_chan *chan * microblock. */ descs_list = &desc->descs_list; - list_for_each_entry_safe(desc, _desc, descs_list, desc_node) { - dwidth = at_xdmac_get_dwidth(desc->lld.mbr_cfg); - residue -= (desc->lld.mbr_ubc & 0xffffff) << dwidth; - if ((desc->lld.mbr_nda & 0xfffffffc) == cur_nda) + list_for_each_entry_safe(iter, _desc, descs_list, desc_node) { + dwidth = at_xdmac_get_dwidth(iter->lld.mbr_cfg); + residue -= (iter->lld.mbr_ubc & 0xffffff) << dwidth; + if ((iter->lld.mbr_nda & 0xfffffffc) == cur_nda) { + desc = iter; break; + } } residue += cur_ubc << dwidth;