Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp35046030rwd; Mon, 10 Jul 2023 01:34:14 -0700 (PDT) X-Google-Smtp-Source: APBJJlHwxzpndsBCqEjqnc2licfcI0AJe0XREI3Rg7Nwmgd+a/0ylrBuRgMayaL8E3P4VfREK+1N X-Received: by 2002:a17:906:cc57:b0:989:21e4:6c6e with SMTP id mm23-20020a170906cc5700b0098921e46c6emr10539171ejb.53.1688978054446; Mon, 10 Jul 2023 01:34:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688978054; cv=none; d=google.com; s=arc-20160816; b=lZdJEMJ9LrggEsNsQA1wcOm72FbkNZeruv5JagNUlRuw6GgWCKWQoMxQzS9wRp9y0u ehAIzSwDF2WWsfmEadHpLfe5ZD4cPgQEDhe0qTA4DmLXeCjvOJZjT3Zrcb7+gsUEHnvF AIHNJ5VVvTl4pU1QwhRSio/Zp44UxtTDoN/KIP6JKn1H/JsbnKpcrXSMPH8Zz6T0Jk4q olyxob1ObAQpjsNFkV9JvZRvOZ7P0H25tAoeyRABzGdmGaHRxFVBMw+bspK9dvpi20gT l5WMDI2aqzIXdjIy/uCd7jC7ZEVeS4GV0fSZ6nWlxqZ1+GPRh4r+uyCUZGfO68+gkpbC FIYg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=DCCwriXuGgjxttdu518jBPuCy8MBEnmenY9om7Nyg3g=; fh=BDDFGzP6DtAXrcnaNDA87KqSZT/NeOSnb+Ik/sQKV/g=; b=CDBCMZ0c7+pmTEh4f8xQMSqgI8Z4tpHRbuBvs/00eBqWkvoYdQsSZ1fPLptB4cqnkW m8jlUeKEj4jWRVLmPIJmDrakLj+i9OnGODc7slTcbQndjp+Zx6qr4WqVVt7riXdrwbXi faA/NhKH0sK5JCJDBhgfB/Dcvgt1wYrvi808DdfS0hdABDIMQFHWj8ky+JcQgkbO+o6H Ty5QRwbaZuBtxHrbcxyKBsK3EN8sIrO3YtBhO5wqmvLX33iTG8JOgpHOPozmk0sUq27e hvnjYYhM1jwSqYj9dt5MIFUhKW2XKQGxWGSzyepTmz0bgABLuqStXUMTJ3qBaqqmTDRd /VgA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e21-20020a17090681d500b00988ccf32c61si8054774ejx.40.2023.07.10.01.33.50; Mon, 10 Jul 2023 01:34:14 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232621AbjGJILk (ORCPT + 99 others); Mon, 10 Jul 2023 04:11:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232291AbjGJILg (ORCPT ); Mon, 10 Jul 2023 04:11:36 -0400 Received: from SHSQR01.spreadtrum.com (mx1.unisoc.com [222.66.158.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63DBFDD; Mon, 10 Jul 2023 01:11:32 -0700 (PDT) Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 36A84RBn047544; Mon, 10 Jul 2023 16:04:27 +0800 (+08) (envelope-from Chunyan.Zhang@unisoc.com) Received: from SHDLP.spreadtrum.com (bjmbx02.spreadtrum.com [10.0.64.8]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4QzxMj1FCxz2M5vH6; Mon, 10 Jul 2023 16:03:29 +0800 (CST) Received: from ubt.spreadtrum.com (10.0.73.70) by BJMBX02.spreadtrum.com (10.0.64.8) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Mon, 10 Jul 2023 16:04:25 +0800 From: Chunyan Zhang To: Greg Kroah-Hartman , Jiri Slaby CC: , Baolin Wang , Orson Zhai , Chunyan Zhang , Chunyan Zhang , LKML Subject: [PATCH 2/2] serial: sprd: Fix DMA buffer leak issue Date: Mon, 10 Jul 2023 16:03:48 +0800 Message-ID: <20230710080348.4137875-2-chunyan.zhang@unisoc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230710080348.4137875-1-chunyan.zhang@unisoc.com> References: <20230710080348.4137875-1-chunyan.zhang@unisoc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.0.73.70] X-ClientProxiedBy: SHCAS01.spreadtrum.com (10.0.1.201) To BJMBX02.spreadtrum.com (10.0.64.8) X-MAIL: SHSQR01.spreadtrum.com 36A84RBn047544 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,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 Release DMA buffer when _probe() returns fail to avoid memory leak. Fixes: f4487db58eb7 ("serial: sprd: Add DMA mode support") Signed-off-by: Chunyan Zhang --- drivers/tty/serial/sprd_serial.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/sprd_serial.c b/drivers/tty/serial/sprd_serial.c index 942808517393..e1f11382fc39 100644 --- a/drivers/tty/serial/sprd_serial.c +++ b/drivers/tty/serial/sprd_serial.c @@ -1203,7 +1203,7 @@ static int sprd_probe(struct platform_device *pdev) ret = uart_register_driver(&sprd_uart_driver); if (ret < 0) { pr_err("Failed to register SPRD-UART driver\n"); - return ret; + goto free_rx_buf; } } sprd_ports_num++; @@ -1222,6 +1222,8 @@ static int sprd_probe(struct platform_device *pdev) sprd_port[index] = NULL; sprd_ports_num--; uart_unregister_driver(&sprd_uart_driver); +free_rx_buf: + sprd_rx_free_buf(sport); return ret; } -- 2.41.0