From patchwork Sat Oct 22 07:19:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7204 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1090065wrr; Sat, 22 Oct 2022 00:45:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM63eDnlqNxKqHPStG3ob0YIp9S/uK8WbqiIkZ5sbRFDGm56GMZfl8fq4Q14iaSrahBznhT2 X-Received: by 2002:a17:902:b093:b0:185:4aa1:402c with SMTP id p19-20020a170902b09300b001854aa1402cmr23424518plr.92.1666424734136; Sat, 22 Oct 2022 00:45:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666424734; cv=none; d=google.com; s=arc-20160816; b=s2Wb2UmXbDdyYj/WUNY4wXz/dHM+ldirQvkbag3u2vwsUPlREVajVG2W7k6KDE6htZ jWbDchtfKWvUPHELhnOCj5GJr6L3aDe5jvYxhmobKPMHOy2ajieu9i1+vUe9hbKMC2LZ yYjxjaG9BpsLJxY4OYMuYEzGaDxbfVYSNy0fCtAeAh2MFdrkxZ3ZKPOvAKQEHUj5RJEd wSNe7a+NUWgtV+SgUwiQLwLbPZGBaxMVfZP/fKxD50mIfFDAjp+++28ZOxLrMK5Bur/k hdlHjHFB7k2ixU5o2D/HwN8nfYhNecfZxNmlSSMHQ5okIsiYBS0cr8V9RmAxqSirxCyr coHA== 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=0Iu0U5WwratT+qC9qW/lDkrKie8f6zBk3yq+2/poxVA=; b=01uPWl9TFMYsn0fAjPdlG43/mL6TA6CJ9ncKe/KXGa+LKNLxVOdHJxHM4n5Xwtajeg SvBHGLHTkf6h6Xc8XRu27D+aCdrdHb6m/k0++n7rWlBDQ31tcCzJVP9jBNbkA1CyByEB QLnhErfNh0nUid9vQUdmI0n+Dr9SQv3H1wiY9FHoV6xwfxANr9Br8u4/Da0gztD8M5fR N+cCU+xYgldSdWhiYOzyLQPl55XojAmbWs9xuwy6x60/B3Az4oWq9bAxekugM6yAuDRX LzkrDdrU/5f9Zj8boFUg4cHwUoNKdkOu08MXSEsMKOlR/V42wqL/k/z7U7fjUByKXpTb z9fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=c9msrEMM; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m3-20020a056a00080300b00535d7265923si31160654pfk.377.2022.10.22.00.45.21; Sat, 22 Oct 2022 00:45:34 -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=c9msrEMM; 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 S230450AbiJVHpO (ORCPT + 99 others); Sat, 22 Oct 2022 03:45:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231293AbiJVHnN (ORCPT ); Sat, 22 Oct 2022 03:43:13 -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 AB03A38A00; Sat, 22 Oct 2022 00:41:57 -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 BE866B82DE2; Sat, 22 Oct 2022 07:38:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34B1AC433C1; Sat, 22 Oct 2022 07:38:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424305; bh=DKXEvkae9Qlu8kF9vn+0R4ngMyO0P2H39NsbsvQknGY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c9msrEMMG0EPTjxhVZzGcVm8itRhXi6mrAc5MHcrGeRr8u3g0cCAGIcEqVJp9wp9i b9M9WXRPnt+rOa9MagtmGE1kmfX4WiZNeXCsz4n1W0QOdxBku7A7Kgqk3EdWC1zRtm 53Moy4pvXS1S62SzE5Cw9rLpI822KosvcKEwn17A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christian Marangi , Vinod Koul Subject: [PATCH 5.19 066/717] dmaengine: qcom-adm: fix wrong calling convention for prep_slave_sg Date: Sat, 22 Oct 2022 09:19:05 +0200 Message-Id: <20221022072426.784470704@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747372981974386308?= X-GMAIL-MSGID: =?utf-8?q?1747372981974386308?= From: Christian Marangi commit b9d2140c3badf4107973ad77c5a0ec3075705c85 upstream. The calling convention for pre_slave_sg is to return NULL on error and provide an error log to the system. Qcom-adm instead provide error pointer when an error occur. This indirectly cause kernel panic for example for the nandc driver that checks only if the pointer returned by device_prep_slave_sg is not NULL. Returning an error pointer makes nandc think the device_prep_slave_sg function correctly completed and makes the kernel panics later in the code. While nandc is the one that makes the kernel crash, it was pointed out that the real problem is qcom-adm not following calling convention for that function. To fix this, drop returning error pointer and return NULL with an error log. Fixes: 03de6b273805 ("dmaengine: qcom-adm: stop abusing slave_id config") Fixes: 5c9f8c2dbdbe ("dmaengine: qcom: Add ADM driver") Signed-off-by: Christian Marangi Cc: stable@vger.kernel.org # v5.11+ Link: https://lore.kernel.org/r/20220916041256.7104-1-ansuelsmth@gmail.com Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman --- drivers/dma/qcom/qcom_adm.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) --- a/drivers/dma/qcom/qcom_adm.c +++ b/drivers/dma/qcom/qcom_adm.c @@ -379,13 +379,13 @@ static struct dma_async_tx_descriptor *a if (blk_size < 0) { dev_err(adev->dev, "invalid burst value: %d\n", burst); - return ERR_PTR(-EINVAL); + return NULL; } crci = achan->crci & 0xf; if (!crci || achan->crci > 0x1f) { dev_err(adev->dev, "invalid crci value\n"); - return ERR_PTR(-EINVAL); + return NULL; } } @@ -403,8 +403,10 @@ static struct dma_async_tx_descriptor *a } async_desc = kzalloc(sizeof(*async_desc), GFP_NOWAIT); - if (!async_desc) - return ERR_PTR(-ENOMEM); + if (!async_desc) { + dev_err(adev->dev, "not enough memory for async_desc struct\n"); + return NULL; + } async_desc->mux = achan->mux ? ADM_CRCI_CTL_MUX_SEL : 0; async_desc->crci = crci; @@ -414,8 +416,10 @@ static struct dma_async_tx_descriptor *a sizeof(*cple) + 2 * ADM_DESC_ALIGN; async_desc->cpl = kzalloc(async_desc->dma_len, GFP_NOWAIT); - if (!async_desc->cpl) + if (!async_desc->cpl) { + dev_err(adev->dev, "not enough memory for cpl struct\n"); goto free; + } async_desc->adev = adev; @@ -437,8 +441,10 @@ static struct dma_async_tx_descriptor *a async_desc->dma_addr = dma_map_single(adev->dev, async_desc->cpl, async_desc->dma_len, DMA_TO_DEVICE); - if (dma_mapping_error(adev->dev, async_desc->dma_addr)) + if (dma_mapping_error(adev->dev, async_desc->dma_addr)) { + dev_err(adev->dev, "dma mapping error for cpl\n"); goto free; + } cple_addr = async_desc->dma_addr + ((void *)cple - async_desc->cpl); @@ -454,7 +460,7 @@ static struct dma_async_tx_descriptor *a free: kfree(async_desc); - return ERR_PTR(-ENOMEM); + return NULL; } /**