Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp497594lqt; Fri, 19 Apr 2024 02:03:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVJ/k8QY3JzY1MFLAv7OgJQoXIg0Ma7ptFG3CTt6M1bqfis2llK++OsyzA7UC/BEcJO7i01uuY28Qw08uducxQaaInur5zKIoB1O76KTw== X-Google-Smtp-Source: AGHT+IGeBl5vH9I20IJ+iQ8w1ZEtn583eSjP8fvaSS6+sC/h4q7k5fDQSSGmo+QdA/cKGJ96QMqG X-Received: by 2002:a17:906:408c:b0:a55:54ea:12f8 with SMTP id u12-20020a170906408c00b00a5554ea12f8mr1089845ejj.36.1713517435831; Fri, 19 Apr 2024 02:03:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713517435; cv=pass; d=google.com; s=arc-20160816; b=Hspj7hTMTmlxYBx+RS9aOnlahvT/oI6R8+4ANoPtXQjXlghiVtgdF9hrKBsTiDDvLW tQuXRGxVaw8S0QGbVSu+9ip4sAA6QdXj6f4cUcCNTQHCqpZHa9woC8/nwjSdknbOGSpV /hGXV6V2Bh4wQNS8D6lRtsbdaIkqhFnUxCD/l0eeiZqQ7semP4ggvkzYpABlFYx/BxoP QYihyZfKBoRfc983Q8KUgirCR4ha5HcnT1BcbCOFak/rRilefbidMLEMmB/hagAsLYpJ 27dfxI4YL9ZN4/RygVyhFlWP1lTTbPmkleLTKDvFO/y8hIfg7cdyrhg88Aif0217ET3W UnAQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:cms-type:content-transfer-encoding:in-reply-to:from :content-language:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature:dkim-filter; bh=5epo2hFNGdItoVB1/oi1I+wZXv4cgIPH4R+qqziczOI=; fh=D6v4PboWj0J88up9Ep/4Tvi46uFdR0vxO4BLbBhPUaw=; b=eefaGO4KH/tngWwE1hdcqrAc9JBn887XCGUkPqfYNT/6wFXggTG3OOPRe3Gs+by23Q X4/R5ZPjFDCdeSZoG2Tlmqd8lOdsLK+vOGeXXPbZNiHlmfWUyCn1qhsfkvU+ohilHLT7 7l9jI9/OK1ZOsdXo6Fx49tivGbFnvlU7DcGH1bfakgYn0uy1RIAzt8I2v06Ybjnals/k 2Pkiu18sW/bLu4l4LhhvNj7s7Oy5jKwNWg1YqA1GYcJBwELwruc9z6bfp2epVWfkBD51 /pX2aUo9l/UqPbW+4/dyZO1W8KAxBWLrJlEaa2bA9j0yuWA5p0F+Bqqax6s4z9ucX5wc RYHg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=QXpQWEow; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-151209-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151209-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id qf38-20020a1709077f2600b00a5571f7131bsi2015712ejc.159.2024.04.19.02.03.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 02:03:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-151209-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=QXpQWEow; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-151209-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151209-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 5B0721F21FC5 for ; Fri, 19 Apr 2024 09:03:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6D45D69DFB; Fri, 19 Apr 2024 09:03:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="QXpQWEow" Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D44B3651B6 for ; Fri, 19 Apr 2024 09:03:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.118.77.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713517427; cv=none; b=rUvxxXZlktSDqA6AOqOZruZq/X+hYfMdnO0wN6xR3LdvEh5qUaTC0TzyJ8/GW/7fb8gM6IgcVc//xOWdwu/j1NHCl4hby56j7i0BH1bqz34pGxweKl4SdEi38oz6czT4BFUCVC+0+Afo2JItCKfJY1J0Cv/rA9cB4XvZXHi6Qho= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713517427; c=relaxed/simple; bh=e4fxTG9IOEhRJ2oy+q+Z2QsiJ7pgDkrpf7Ps9FXu6MQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:From:In-Reply-To: Content-Type:References; b=jsz7+9qw6gzmmlk0Xa/xk+RNbk0LAPPxPn7dKNy0eU42ufwn9z7G3zYuXPgapSUElLyzgwYSxm0qoCfTjJUQLA7WXRvRVAQu3LQ4vaLj3MjhQdJvjPkENL0dVXKIlgzz7b33n6Ix2xNiB+9Pzhv9HEFFD7kQvWRSzOys7UmeTAk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=QXpQWEow; arc=none smtp.client-ip=210.118.77.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20240419090337euoutp028afad3b3d0fa45ba09f97e525db5e25a~HowMnqGNg1247212472euoutp02x for ; Fri, 19 Apr 2024 09:03:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20240419090337euoutp028afad3b3d0fa45ba09f97e525db5e25a~HowMnqGNg1247212472euoutp02x DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1713517417; bh=5epo2hFNGdItoVB1/oi1I+wZXv4cgIPH4R+qqziczOI=; h=Date:Subject:To:Cc:From:In-Reply-To:References:From; b=QXpQWEowhE3Vyr+TulZX4n1uylvZEHaGK0d7NDRlG5CpHWuniEg3rSV5A4SQf4CLH 5OWdFn9kp8tHZqZDG+yK6eqPuJQDm9bxp0DwMHLd1kCsqtof/G4b6w26KYtAIIncc+ 5aReWLvo+2hJKeaXG3cui2d0TNAX0oMvO7M4Y4l8= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20240419090336eucas1p2090739cbb7fd29dcede241151823357a~HowMR7Sfo0628006280eucas1p2Y; Fri, 19 Apr 2024 09:03:36 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 44.F3.09624.86332266; Fri, 19 Apr 2024 10:03:36 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20240419090336eucas1p17674ea65e993d1681fea157e46e2b059~HowL8xCMG2506225062eucas1p1A; Fri, 19 Apr 2024 09:03:36 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240419090336eusmtrp18787ba7327372849526ebcc458a53dac~HowL8L-Em2605826058eusmtrp1V; Fri, 19 Apr 2024 09:03:36 +0000 (GMT) X-AuditID: cbfec7f2-c11ff70000002598-f0-662233687f18 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 6A.CC.09010.86332266; Fri, 19 Apr 2024 10:03:36 +0100 (BST) Received: from [106.210.134.192] (unknown [106.210.134.192]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240419090336eusmtip2fe7f576e4a49e16e0fd0fdf5701fa2ff~HowLnqshL0629206292eusmtip2c; Fri, 19 Apr 2024 09:03:36 +0000 (GMT) Message-ID: <92492ec0-bde6-46ad-a2b4-840b60c85652@samsung.com> Date: Fri, 19 Apr 2024 11:03:35 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] serial: msm: check dma_map_sg() return value properly To: "Jiri Slaby (SUSE)" , gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Content-Language: en-US From: Marek Szyprowski In-Reply-To: <20240419080931.30949-1-jirislaby@kernel.org> Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmphleLIzCtJLcpLzFFi42LZduznOd0MY6U0g5kbtS2aF69ns3g3V8bi 8q45bBZnFveyO7B4bFrVyeaxf+4ado/Pm+QCmKO4bFJSczLLUov07RK4Mk5e+8te8Ja/4s81 tQbGxzxdjJwcEgImErs/LmTqYuTiEBJYwSjxdscCNgjnC6PE+YvvGCGcz4wSDSs3scC0rFzy FKpqOaPE4+bnLBDOR0aJqTM3MYJU8QrYSUzq+cQGYrMIqEp8fXSBGSIuKHFy5hOwSaIC8hL3 b81gB7GFBbwktk/bygRiiwDZpyY/AZvDDDRn2pOLLBC2uMStJ/PBatgEDCW63naBzecUsJJ4 3DeFDaJGXmL72znMIAdJCKzlkGhddZgJ4mwXiZ/dD5ghbGGJV8e3sEPYMhKnJ/ewQDS0M0os +H2fCcKZAPT081uMEFXWEnfO/QJawQG0QlNi/S59iLCjROv/SywgYQkBPokbbwUhjuCTmLRt OjNEmFeio00IolpNYtbxdXBrD164xDyBUWkWUrDMQvLmLCTvzELYu4CRZRWjeGppcW56arFh Xmq5XnFibnFpXrpecn7uJkZgQjn97/inHYxzX33UO8TIxMF4iFGCg1lJhNeMQzFNiDclsbIq tSg/vqg0J7X4EKM0B4uSOK9qinyqkEB6YklqdmpqQWoRTJaJg1Oqgakl3+9FUjovo2p9SMzs M+6LOCZ07RV6of7D//7jl8eefNEs3Lxv9xfFi9wnTnv2xbC2/IyVfm69Tn32Of+Q3616dQ1L gwx3/lRb9fbnQbuksK5YUzajqf/n1IoF3euRfey9lWup2uupn648eyWmscEld9PKh9rbeuKv 7BBRUvyxLebE7W2HvkbcEkjdcitViPV6p2JQWHuJ02nW/Z6/nrf9VtjZoP8s4q3Pvh0LStnf NfYu3/as4T8T+8StElWq1z478mxwDHj4xS7cRuHmSofQCe3m6s8zg022NF8UDmaPv2o6J+ng O3Yld9Mzy845m7uGT2j8PaWH847S1sd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CMS-MailID: 20240419090336eucas1p17674ea65e993d1681fea157e46e2b059 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20240419080939eucas1p1ab74bd6b995e53135ece92bc4260d334 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20240419080939eucas1p1ab74bd6b995e53135ece92bc4260d334 References: <20240419080931.30949-1-jirislaby@kernel.org> On 19.04.2024 10:09, Jiri Slaby (SUSE) wrote: > The -next commit f8fef2fa419f (tty: msm_serial: use > dmaengine_prep_slave_sg()), switched to using dma_map_sg(). But the > return value of dma_map_sg() is special: it returns number of elements > mapped. And not a standard error value. > > The commit also forgot to reset dma->tx_sg in case of this failure. > > Fix both these mistakes. > > Thanks to Marek who helped debugging this. > > Signed-off-by: Jiri Slaby (SUSE) > Reported-by: Marek Szyprowski Tested-by: Marek Szyprowski > --- > drivers/tty/serial/msm_serial.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c > index ae7a8e3cf467..0a9c5219df88 100644 > --- a/drivers/tty/serial/msm_serial.c > +++ b/drivers/tty/serial/msm_serial.c > @@ -499,15 +499,18 @@ static int msm_handle_tx_dma(struct msm_port *msm_port, unsigned int count) > struct uart_port *port = &msm_port->uart; > struct tty_port *tport = &port->state->port; > struct msm_dma *dma = &msm_port->tx_dma; > + unsigned int mapped; > int ret; > u32 val; > > sg_init_table(&dma->tx_sg, 1); > kfifo_dma_out_prepare(&tport->xmit_fifo, &dma->tx_sg, 1, count); > > - ret = dma_map_sg(port->dev, &dma->tx_sg, 1, dma->dir); > - if (ret) > - return ret; > + mapped = dma_map_sg(port->dev, &dma->tx_sg, 1, dma->dir); > + if (!mapped) { > + ret = -EIO; > + goto zero_sg; > + } > > dma->desc = dmaengine_prep_slave_sg(dma->chan, &dma->tx_sg, 1, > DMA_MEM_TO_DEV, > @@ -548,6 +551,7 @@ static int msm_handle_tx_dma(struct msm_port *msm_port, unsigned int count) > return 0; > unmap: > dma_unmap_sg(port->dev, &dma->tx_sg, 1, dma->dir); > +zero_sg: > sg_init_table(&dma->tx_sg, 1); > return ret; > } Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland