Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3159191imw; Mon, 11 Jul 2022 03:11:37 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tIX1gXOuAoOrkzgY56hDBU1JKBEpbKKcmAWNfE4xqYDxtGL9IPkU7iGiGL+vAMXgoxnKDS X-Received: by 2002:a05:6402:26c3:b0:43a:a846:b2c1 with SMTP id x3-20020a05640226c300b0043aa846b2c1mr23750387edd.133.1657534296789; Mon, 11 Jul 2022 03:11:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657534296; cv=none; d=google.com; s=arc-20160816; b=kKKXRjBnwojBaynDggWkS3wMdDpC6KBAIiItCud2re9Tgi/Cb6EGG9MIjgzZNpZudl +GZUtAnpSE7ov10wN3xekteRE93n8oOakdlcgsLLvmx817y1xDX2qOGN5/o1uDJML0I/ sXZuf64KkdOMxL96oxBylXYRvgEkLaoJal2wrj/JFq0sf1Zw623H6TDW6HXoZWNg4Jeo H27JBPOWTSC7l7f0k5a294vtkq33h5ZTSN3rZ7WaX78TyhmrhBzyvBlCyWM5d/HpmS3k FMq4KQfxVtQbW/osUERHWF0xApJZaUmx4veNGxo9e4B9ftL6VirfIo400coWg4dQa9WG pQ1Q== 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=SMSsjQl1X70bnIGKMy5R0GK8fpKU1G4LklhR1Aa8pN4=; b=Rn59cNLjc8VLpwdnqaEPxqK0aS2mNjLYr6+vFgVGkP/RlFPvbjYzaVqzgDq9zmeQBw ObQYgZgYnwefVuVfoLYR7kVsC3q9bvDIe4byxelz9mC88ujzZXT3Uq3YLDFVl6/nfzq6 L9szQd4HQtvxNIEMiqhq/JA3U6lI3MwcbPDK5q0vUHfv2WfDI65o8l3MqLyLHpD4951i WRiwCqDjSQASA93ej71nyBJ8gaEQdpfmIM5dKefKqYE9TLOjLy3D9jdvQPVACzppgpDc u0Hx0GJhXdGYUTfM1qbyl0Bw3PzDqj46eYTwgABqCjIE5bWWmnDljAfGL3Rgz0Er/doe IW1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xULFXLQy; 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 gb41-20020a170907962900b0072b4cba9671si6158930ejc.186.2022.07.11.03.11.11; Mon, 11 Jul 2022 03:11:36 -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=xULFXLQy; 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 S231422AbiGKJNI (ORCPT + 99 others); Mon, 11 Jul 2022 05:13:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231400AbiGKJMd (ORCPT ); Mon, 11 Jul 2022 05:12:33 -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 966CE24BFC; Mon, 11 Jul 2022 02:09:24 -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 4562DB80E7B; Mon, 11 Jul 2022 09:09:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9226DC34115; Mon, 11 Jul 2022 09:09:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657530561; bh=8tFdo+OIIS3mTEzo0rS2Tz8lJWzmLaRAn8Rg1nhuTjE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xULFXLQyMza2rmd2oqtH1IxfUEEOzIp+AtDroZa+7y/LrWkUoEHLI5HBEx6uPaAMK DDifTYQ/zfhqkVnOghoDRBU1/a880hVEh6WottnXxkk22R9ZJomvRdw6PmipOfqIy7 GA8kfO7LZd1LN/13yfyD4OhgrZgKMTjuNh/Y2Qx8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Walle , Vinod Koul Subject: [PATCH 4.19 29/31] dmaengine: at_xdma: handle errors of at_xdmac_alloc_desc() correctly Date: Mon, 11 Jul 2022 11:07:08 +0200 Message-Id: <20220711090538.706635240@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090537.841305347@linuxfoundation.org> References: <20220711090537.841305347@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 @@ -1804,6 +1804,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;