From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1477DC77B7E for ; Sun, 28 May 2023 19:19:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229866AbjE1TTJ (ORCPT ); Sun, 28 May 2023 15:19:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229871AbjE1TTI (ORCPT ); Sun, 28 May 2023 15:19:08 -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 437D7DF for ; Sun, 28 May 2023 12:19:05 -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 CDE9E61A8B for ; Sun, 28 May 2023 19:19:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDF3BC433D2; Sun, 28 May 2023 19:19:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1685301544; bh=htDnQPPTK0T6AosbxRErJZ2KbgQTcim5FlO8G19BaE4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OfykG+f5mCSN6DvMFm1Rhhxvoh410zk3hiVuGnR3amE+SyCJIsdfwfHUlLda5Gaqx h0orw7po2RpilrjTx2ETjC10ddnXJlLpqXaflX9WZz0AulieXVI+Wu36bwoeKSzbFu JoohX0lQno7biKxs928KEenu07tr91/SisZgDWu4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ke Zhang , Dongliang Mu , Sasha Levin Subject: [PATCH 4.19 054/132] serial: arc_uart: fix of_iomap leak in `arc_serial_probe` Date: Sun, 28 May 2023 20:09:53 +0100 Message-Id: <20230528190835.221759471@linuxfoundation.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230528190833.565872088@linuxfoundation.org> References: <20230528190833.565872088@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Ke Zhang [ Upstream commit 8ab5fc55d7f65d58a3c3aeadf11bdf60267cd2bd ] Smatch reports: drivers/tty/serial/arc_uart.c:631 arc_serial_probe() warn: 'port->membase' from of_iomap() not released on lines: 631. In arc_serial_probe(), if uart_add_one_port() fails, port->membase is not released, which would cause a resource leak. To fix this, I replace of_iomap with devm_platform_ioremap_resource. Fixes: 8dbe1d5e09a7 ("serial/arc: inline the probe helper") Signed-off-by: Ke Zhang Reviewed-by: Dongliang Mu Link: https://lore.kernel.org/r/20230428031636.44642-1-m202171830@hust.edu.cn Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/arc_uart.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c index d904a3a345e74..dd4be3c8c049c 100644 --- a/drivers/tty/serial/arc_uart.c +++ b/drivers/tty/serial/arc_uart.c @@ -613,10 +613,11 @@ static int arc_serial_probe(struct platform_device *pdev) } uart->baud = val; - port->membase = of_iomap(np, 0); - if (!port->membase) + port->membase = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(port->membase)) { /* No point of dev_err since UART itself is hosed here */ - return -ENXIO; + return PTR_ERR(port->membase); + } port->irq = irq_of_parse_and_map(np, 0); -- 2.39.2