From patchwork Wed Oct 19 08:22:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4577 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp205319wrs; Wed, 19 Oct 2022 01:49:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6AGWNNuq015Ipb44IxsRFzeZxVvHZF7zYM/NS2QjFw5rIP/VNfk3wbV1xMKqpg+bU9/0AV X-Received: by 2002:a17:902:b589:b0:17f:5756:b3f9 with SMTP id a9-20020a170902b58900b0017f5756b3f9mr7415648pls.14.1666169344399; Wed, 19 Oct 2022 01:49:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666169344; cv=none; d=google.com; s=arc-20160816; b=qBIv4XmbMcnazbGKR03ckI5LIDNG8gK5qaC/3DhU164jx9LiBbG1QVRtF1KD+EPbM7 CcocG6R0h9cMaL1QwCBqGEZdvQF8h40y6dgVt9LrcQN4ihgrW5BFjgmyk8ibuStEyBSd JkOAetIibik2ZaekoDulE1BcMwiFs6GDC+pvxEsnxjy+uAFbwzR3X9VKLdgF7oTT3zAJ Ln42qwj8WGmcClytbIT/iHKHccuPaNRYsHt0UzR7FuiX6eibQZaDNHuLhK26N/TPsHUR +g0U/YyU6sodCJPsRXjxuim2MTM/UuPDpdeBk9JiLZ9s4LBPyi/ELw2NTCiII6LG5Sn7 B0Ww== 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=sSa8epCXrsVuqdHGz/PYY6niLdwibO9wt3e4amQzLZ/DLFjdFWhOv0O2Z9p7wHLfqr a8CT2TBFP1LCyPo3MJhs2XVrNzDzUMxgkUtiyF4vi+1konk7ZccOAZNaUs86Pz22I7Kb fJwfWsMGcoNLPY5IDh3l1XdTpI5+lkRPLM8AbVDR+VU8gdRQ3zZHkBrwZz3w8xE94ghZ TAyfguyUsl1BO91Mjj9VWrK9eTzhBY5S9FBeBX0RWX/XdcwQ5Rc0Oz1z1zl1mdNHfGdO g49uVIwlvqyudVHdtUoEO06kXHFJ020hpSIxNV8hJ5J4SA+gs9OQFjiBPC9k3pkteNvK NA3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="pf3+/k5i"; 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 k6-20020a17090a39c600b0020cccdfc970si27727280pjf.121.2022.10.19.01.48.49; Wed, 19 Oct 2022 01:49:04 -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="pf3+/k5i"; 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 S231617AbiJSIs1 (ORCPT + 99 others); Wed, 19 Oct 2022 04:48:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231329AbiJSIry (ORCPT ); Wed, 19 Oct 2022 04:47:54 -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 0EBD868882; Wed, 19 Oct 2022 01:45:39 -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 6004761804; Wed, 19 Oct 2022 08:42:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71665C433D6; Wed, 19 Oct 2022 08:42:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666168961; bh=DKXEvkae9Qlu8kF9vn+0R4ngMyO0P2H39NsbsvQknGY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pf3+/k5irivnJHcVhHx5pNJDwKxPwej9CzZN6KbU0hieVBgkQD/opq/VbuXA8x+Ur MJ7V1XKlytOiheIkdpReqZbBEcGLnKN0Qy9KB41qkHmac6dr2tWzRBSxyWZaWtHyel S4Zj6OERf8UTgNZ0r2Dg4dMlRCAvfFNYgol0sVF8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christian Marangi , Vinod Koul Subject: [PATCH 6.0 073/862] dmaengine: qcom-adm: fix wrong calling convention for prep_slave_sg Date: Wed, 19 Oct 2022 10:22:40 +0200 Message-Id: <20221019083253.160008981@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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?1747105186224579779?= X-GMAIL-MSGID: =?utf-8?q?1747105186224579779?= 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; } /**