Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3178724imw; Mon, 11 Jul 2022 03:39:46 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tA6sRXDeXT7aMXoqV7uxa+Z/Jv2oOUxS9orFRo2Hywhc3j5x8XcQi8ZpGCncbh/8PkGrU7 X-Received: by 2002:a17:907:2889:b0:72b:50c8:c703 with SMTP id em9-20020a170907288900b0072b50c8c703mr5434277ejc.694.1657535986562; Mon, 11 Jul 2022 03:39:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657535986; cv=none; d=google.com; s=arc-20160816; b=ZBig92PHO3vzh78GLO+HForfdt7qPFWV+wSyJRPwGsEqxX5d3S5QJsk1aPYjyUfMGY W/sNVHvOYE+x99CQQLQi9CUgS9KI+yP8EwFopKu143PxGE7Mla1bzMRJ45OoylZzRoZq Up/Mq4dyEJ79wv3FUk1AHEKGSoG09sRnes3ZAGSn1VDXRM4+5wV945snfFK/UTvJA7zn KE7gH3xPruDZIty9DtaYAMkUY3xJ1IlmnT4GXserbQ/q7eyEI9m8m7fRuHwam5YY1WAc bmkpMF9FEOwZocdd5QkuiETSfyLt546MwJ03JdU5tCgiXp6RUwjTTpYocg65nNjNTt3W y/mQ== 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=qBA9ESnKfiq3XmwBhLb9luf1hu9tEX0aTCNdIW3t3g8=; b=fAZhtWdVPpo1bHHgpgzJvtcjkYo95qiPcR+vFOGATytHiF0xeGBO5p6WMjbp+Voi3o 6TsKB/M1z6sKHdw7Cwsh1p2hZr2mvXtooA3ek/YL26hlnNSSW27upwHT5X7SYawTP0Ht KWb7DwYt6YtW+b/76C3st+tLGnwBEKcCLrgo5r+v6qQFMeN1Zi+rO3/WFVtiik2qdYnV NaV+D+hwhOGKPs928hxMzZGqvTbagskfTKBIl0FPpsF4bsfVYRWVCpQBJaZz9y5jmfSt khWaj879TCz4UUO4yO8yF0CqlODQsVOek5aEuf6ktS0X94k4ikKyOuYTLgI3atH8gsRY zJdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="gAe//7fE"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w9-20020a05640234c900b0043a798534b8si11208234edc.33.2022.07.11.03.39.22; Mon, 11 Jul 2022 03:39:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="gAe//7fE"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231515AbiGKJRa (ORCPT + 99 others); Mon, 11 Jul 2022 05:17:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231477AbiGKJRB (ORCPT ); Mon, 11 Jul 2022 05:17:01 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D02542AF7; Mon, 11 Jul 2022 02:11:11 -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 ams.source.kernel.org (Postfix) with ESMTPS id 7A7ACB80E5E; Mon, 11 Jul 2022 09:11:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9C03C34115; Mon, 11 Jul 2022 09:11:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657530669; bh=7+wQWifZoehsBLdojVlQMAj1oNFB+5tvGwcAx1N7vNc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gAe//7fERabEjaNlEPcwMhqGqxB6t0gGlX6Xsyno2u9QW74aCl8bSTERLRljmV7wl 09D8KLwRLliFsq/+/VWnATwv/oSYDBlN6zcjxP7OSy45BPLQDU0VnJSWD/NkMjGBYx 2sN3GotkS9fbWUn5LjGR8gBpSOCDeCM2QbSoIBVk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Walle , Vinod Koul Subject: [PATCH 5.4 36/38] dmaengine: at_xdma: handle errors of at_xdmac_alloc_desc() correctly Date: Mon, 11 Jul 2022 11:07:18 +0200 Message-Id: <20220711090539.789841287@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090538.722676354@linuxfoundation.org> References: <20220711090538.722676354@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=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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: Michael Walle commit 3770d92bd5237d686e49da7b2fb86f53ee6ed259 upstream. It seems that it is valid to have less than the requested number of descriptors. But what is not valid and leads to subsequent errors is to have zero descriptors. In that case, abort the probing. Fixes: e1f7c9eee707 ("dmaengine: at_xdmac: creation of the atmel eXtended DMA Controller driver") Signed-off-by: Michael Walle Link: https://lore.kernel.org/r/20220526135111.1470926-1-michael@walle.cc Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman --- drivers/dma/at_xdmac.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/dma/at_xdmac.c +++ b/drivers/dma/at_xdmac.c @@ -1848,6 +1848,11 @@ static int at_xdmac_alloc_chan_resources for (i = 0; i < init_nr_desc_per_channel; i++) { desc = at_xdmac_alloc_desc(chan, GFP_ATOMIC); if (!desc) { + if (i == 0) { + dev_warn(chan2dev(chan), + "can't allocate any descriptors\n"); + return -EIO; + } dev_warn(chan2dev(chan), "only %d descriptors have been allocated\n", i); break;