From patchwork Sat Jun 10 15:59:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 105983 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1634246vqr; Sat, 10 Jun 2023 09:32:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6ZDa63E/hD6iLzscJZo4kEAlpcSKLVaDBfp4ecTO0Ps6jVhxXDiJ2Dt/qez1oXGSPaAi6M X-Received: by 2002:a17:902:e744:b0:1b2:6054:862d with SMTP id p4-20020a170902e74400b001b26054862dmr2863073plf.50.1686414719711; Sat, 10 Jun 2023 09:31:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686414719; cv=none; d=google.com; s=arc-20160816; b=m+7OVmcw7NHaFxO1vum4z0Rrk+k3eiAsdfd9U3UTdX4dN12Xs7zMyY1QdoM8PcDkvb 9KF10PMGGDqo77LlLY2xeJ+t0kIVaEwKK4coBa1NvuY5888ehIFnZblDf2CPPvoBx3f1 2OFGvRWRYynPsZ54IRwY7Fyik/aPWMApTMw43J3MR0Ungk4euf6P6nQ/Fs5GdoxJhIeT rqbIVTA4BTxyIBxv2NEp6qnRBefy2kc4hBYZNvTHwCLnEUnrUy9LMzjyXRpMq7xNfRdG xbW/+lK36rGJyfULtXD4/i1mWkbQDcFSR9LYqtXE+MkK3j/obGB0wDFt3VLsKOmTE5Ad SqNg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=eYz8VPeFQqWxDk20aGLkAdXUCS+n+oiCg0u8zmpFgg4=; b=NtUHT+mavAkM/ycZez8AQOIkDJnvjPgfZ7oY9IMF2H22wZgjOSLZ6sjCG92bOdVZ/J p6uLWu9t6UuvTHEIjBrQkbBY+PxnSjkSrNChakzHnKC3e+AzP0Xaj6H+y8um+tks8bC/ DksoU8ZYv2uuogX49oAPAOrAfvZat0VG2UIAwgaT+pa4ZAL+NPzyS+XYNVhvjqtJ3XEr aGH8/+RE5f4Q+N7gAazLeiox2xU4AubAoSOf+B5D1fr4r0A+Emjf+zXIAAK1cfGJ7vrm rt9s9pUJ2LoHhgPLQW5vCZc5HPhqmSv7gTpZK4jHfTqCffN9t+zmYYigKu1YSXihkWli QyZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b="E8Qj0/JL"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b3-20020a170903228300b001b06fa47440si4583314plh.352.2023.06.10.09.31.46; Sat, 10 Jun 2023 09:31:59 -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=@wanadoo.fr header.s=t20230301 header.b="E8Qj0/JL"; 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 S232950AbjFJP7l (ORCPT + 99 others); Sat, 10 Jun 2023 11:59:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234767AbjFJP7j (ORCPT ); Sat, 10 Jun 2023 11:59:39 -0400 Received: from smtp.smtpout.orange.fr (smtp-14.smtpout.orange.fr [80.12.242.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71C8430C0 for ; Sat, 10 Jun 2023 08:59:35 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id 80zwqFULNV4eY80zwqBQ53; Sat, 10 Jun 2023 17:59:31 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1686412773; bh=eYz8VPeFQqWxDk20aGLkAdXUCS+n+oiCg0u8zmpFgg4=; h=From:To:Cc:Subject:Date; b=E8Qj0/JL7wXord7afU38rc3n79/MyJkTu9RoEy31bYmwu28ifvGXbl5BpuaZT3Hm0 ZMu2c2rh3BL9b0I7vv//Wxp/IycEhvrXU3HngRiLoVYhfdRS4UVqqggKwIuRjECb5M qExQpuOlxDeBnqha/k40ziJRbOn48aiXSx7qVz2fbXtvyyoexduy+oNBO0ul4uohHk GjAmEjtarIYSttr0kx2ITF2IR0sD8m6dSLaRYOfnLG8QsnVTIvb9dr/HQlBc7jUk76 vQEsrGwPow6A664QSjFgWUM5neBLeI39ZPl8k4qd4Z5cg1XuHQL5wRewPvRtwYw0Vd 8+NFaD1kuUBjA== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 10 Jun 2023 17:59:31 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Krzysztof Kozlowski , Alim Akhtar , Greg Kroah-Hartman , Jiri Slaby , Thomas Abraham , Kukjin Kim Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , stable@vger.kernel.org, Andi Shyti , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-serial@vger.kernel.org Subject: [PATCH v2 1/3] tty: serial: samsung_tty: Fix a memory leak in s3c24xx_serial_getclk() in case of error Date: Sat, 10 Jun 2023 17:59:25 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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?1768334001049517635?= X-GMAIL-MSGID: =?utf-8?q?1768334001049517635?= If clk_get_rate() fails, the clk that has just been allocated needs to be freed. Cc: # v3.3+ Reviewed-by: Krzysztof Kozlowski Reviewed-by: Andi Shyti Fixes: 5f5a7a5578c5 ("serial: samsung: switch to clkdev based clock lookup") Signed-off-by: Christophe JAILLET Reviewed-by: Jiri Slaby --- v2: Add an error message [Andi Shyti] Add Cc: stable [Andi Shyti] Add R-b tags v1: https://lore.kernel.org/all/e4359d5ef206f5b349c1d15a515a1205e78dda55.1686285892.git.christophe.jaillet@wanadoo.fr/ Slightly unsure if Krzysztof's R-b should be kept or not. v2 is not the same as v1, but the change looks small. Sorry if I did wrong. --- drivers/tty/serial/samsung_tty.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c index 2a7520ad3abd..a92a23e1964e 100644 --- a/drivers/tty/serial/samsung_tty.c +++ b/drivers/tty/serial/samsung_tty.c @@ -1459,8 +1459,12 @@ static unsigned int s3c24xx_serial_getclk(struct s3c24xx_uart_port *ourport, continue; rate = clk_get_rate(clk); - if (!rate) + if (!rate) { + dev_err(ourport->port.dev, + "Failed to get clock rate for %s.\n", clkname); + clk_put(clk); continue; + } if (ourport->info->has_divslot) { unsigned long div = rate / req_baud; From patchwork Sat Jun 10 15:59:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 105966 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1625413vqr; Sat, 10 Jun 2023 09:13:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ41/3QjF7bGCcPqvOrTYN6lRiP8YadlxeOt9HF9QPYyFBUKdOGe7pFHu6U0X4KJQQ0iT6LQ X-Received: by 2002:a17:907:9308:b0:975:63f4:4b with SMTP id bu8-20020a170907930800b0097563f4004bmr5292893ejc.36.1686413590793; Sat, 10 Jun 2023 09:13:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686413590; cv=none; d=google.com; s=arc-20160816; b=lusPgomJxDCfLbwaS6sufvAjFfXbRjGkXlVUfW4jI70tOJX/yXDX7b4oS74TGE8a3z 6UbnuBwSjEEwQuC8gAS/jKZqAW7JsIa42j8lrsC5jyWsOCI2v3fJIwApk2Gnxqp0bSyr xoekf9L4Ro4elYNDQREXkH83kHK90SDKVsTOVu0eVUMFZBmfbF7JY6dvjkkowYDvFd2d w3Cy5KYaRum0I4kf9g3alj6qWWB0LrUcHlWnvGHqN/OhI5zWr35t9rTzSGD9JMPHM2X7 dKLi5WctgEPS1JRtMmxJ/0FdImZE86+YB/aLhmzL+rAeHzsmrzIQksFfsTaQzmrZJkRw wZAQ== 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 :dkim-signature; bh=rgPp2pCaELfgMWRAU3EmU6s0PWnLrCfx5I54gIqT2d4=; b=u2iKvuRqiJErKbdN6PYDOCQnH9sJ0aQKooRm/J0ZKPHEmsYXcme4jdx5XYPopxkEep MbzDquN3Jk4ryTGT0/4pTTenVyUK2hd8uxgMSdgWS/EJRRvZHbvJRfYjmFQcoT3GXzaS J5d9k7kdoUPaqedbLeZBvhO51oHqjQbUfLzLm2ByZJFYGoGJFO6r3eYGc+FYoWTdW1hY uT1XGIQFngi+CGCalw63Oi90JX1xG6D0JYKyM4lcUwO4eq+9bHIehEdHyXhKwYfgrC3h 2oCCHFNyOO6Ae4Oj3nLIwY6JDfWr7l+Tn0Wgm2tzfj34oRi4OApPkyPO0gh7XIGS1L5z aUGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=cDOdpzBo; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lc5-20020a170906f90500b00977cf84c426si2834409ejb.427.2023.06.10.09.12.44; Sat, 10 Jun 2023 09:13:10 -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=@wanadoo.fr header.s=t20230301 header.b=cDOdpzBo; 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 S235746AbjFJP7u (ORCPT + 99 others); Sat, 10 Jun 2023 11:59:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235696AbjFJP7o (ORCPT ); Sat, 10 Jun 2023 11:59:44 -0400 Received: from smtp.smtpout.orange.fr (smtp-13.smtpout.orange.fr [80.12.242.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE1E430C0 for ; Sat, 10 Jun 2023 08:59:42 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id 80zwqFULNV4eY8109qBQ5s; Sat, 10 Jun 2023 17:59:41 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1686412781; bh=rgPp2pCaELfgMWRAU3EmU6s0PWnLrCfx5I54gIqT2d4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cDOdpzBoF3bvokNC1MgJ44SiukpgXDu7b2i971OIkrmPMgiv4q3MS+0OIPNqkYG2W DbZDdZbQ8PPHSnqi6TgpnMDf0ALKVQ7De3YcCGtxKgB/Fb/saX4ij4Mm+dWthe2YeM 27EBBuf7tQz1DVgsWoC3wVfhlW+zcWn7KVjUkADyUA7XaDAerMaaYO1Jp4485iilQx Lpihc1DhbjzDcjJMwCduwy3HPVX3IJXdYQu+tI1fEhQOP2sRQ3JRxeOzfZ2oJAzyDQ fEUK9t6UMRt9bLiSwnUKpbNZczmJa4eehmY/H8PyNxjSZEifXdP3qi+IpwmGKVmRNb skhA+uAMYoiMQ== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 10 Jun 2023 17:59:41 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Krzysztof Kozlowski , Alim Akhtar , Greg Kroah-Hartman , Jiri Slaby , Kukjin Kim , Thomas Abraham Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , stable@vger.kernel.org, Andi Shyti , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-serial@vger.kernel.org Subject: [PATCH v2 2/3] tty: serial: samsung_tty: Fix a memory leak in s3c24xx_serial_getclk() when iterating clk Date: Sat, 10 Jun 2023 17:59:26 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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?1768332817520752359?= X-GMAIL-MSGID: =?utf-8?q?1768332817520752359?= When the best clk is searched, we iterate over all possible clk. If we find a better match, the previous one, if any, needs to be freed. If a better match has already been found, we still need to free the new one, otherwise it leaks. Cc: # v3.3+ Reviewed-by: Krzysztof Kozlowski Reviewed-by: Andi Shyti Fixes: 5f5a7a5578c5 ("serial: samsung: switch to clkdev based clock lookup") Signed-off-by: Christophe JAILLET Reviewed-by: Jiri Slaby --- I think that some clk_put() are also missing somewhere else in the driver but won't be able to investigate further. v2: No code change Add Cc: stable [Andi Shyti, as suggested for patch 1/2] Add R-b tags v1: https://lore.kernel.org/all/93bf8f574310256fcea50e5c5a62b5c37e20bb14.1686285892.git.christophe.jaillet@wanadoo.fr/ --- drivers/tty/serial/samsung_tty.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c index a92a23e1964e..0b37019820b4 100644 --- a/drivers/tty/serial/samsung_tty.c +++ b/drivers/tty/serial/samsung_tty.c @@ -1490,10 +1490,18 @@ static unsigned int s3c24xx_serial_getclk(struct s3c24xx_uart_port *ourport, calc_deviation = -calc_deviation; if (calc_deviation < deviation) { + /* + * If we find a better clk, release the previous one, if + * any. + */ + if (!IS_ERR(*best_clk)) + clk_put(*best_clk); *best_clk = clk; best_quot = quot; *clk_num = cnt; deviation = calc_deviation; + } else { + clk_put(clk); } } From patchwork Sat Jun 10 15:59:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 105984 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1635143vqr; Sat, 10 Jun 2023 09:34:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4ToT5xckjWlO13knGucUE/72Atzre5zm0lYxa1KbdyWw2/k358ZA5Cdsv+ihBBq0d4+8Z/ X-Received: by 2002:a05:6a20:728e:b0:10c:3535:162f with SMTP id o14-20020a056a20728e00b0010c3535162fmr6296816pzk.0.1686414844572; Sat, 10 Jun 2023 09:34:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686414844; cv=none; d=google.com; s=arc-20160816; b=oW/AuNMzrFrTaDFVMm4Hf4dZF6qB/Dudm/FmGuGor5dU/P/2vjvnJ4l5SOYkJXurjz yQOSQX4AU7x0LU/llshQhYetiORIn9SFfAd7VnVHTmlZ60vtUhJbqMQJodxTqyN657xV Qhz/kKeUcs1ZHa8nPnVLpYKSPKStu7IZR1630GCivm8y22mx0AYDoMBMvngOERtI9A2/ 2XfMPxnBfk1MO4gJPcPP2L57wrAdovlUa4mQ28v9CjcjsKzBczmvXDGCEBs2xkOIBmRz wPmxd4CspHIdPw11rH8OIP51kz47u4xF45hOAl89uxInpFC+Krca56dEX/aUXQUNTQri cvxw== 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 :dkim-signature; bh=x5Q7JFOBqrMC6o8LYzgUOOfoq0P2ZHbeu6tRAx/Ruf8=; b=eIwfXsEu8Ccfje4H4FmPkW8uCdKFq8P7wU20a1VOVzOsuQKe1qbbJTxvBDlXkr6Vgg ugZ2X6V4c7x+QdKpNQtPRY1v3pywbY1+ngPoq0O7JOdFgBnWMG6bJU6xfSJ3qg3mgkxO MCddPHTl/Z5ddbeHU31S+MHbJilvD/0i46S/VNnvxX3nFSqb/fVeA5YF8pMuPi2avWUd to/6Qn+ARMHTxCd59wkXV9fCwhHqsBiw+pCUks7BNlSRie6HzFRQ5aGRUZtnWBHNkQ46 oIPdJEKHZmLUiurjiJe0zFvfVFqqd61azhs9irPs7xds+tcQ3cylknMvubAnvyqTsScp 55mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b="YY/e99Cu"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k128-20020a633d86000000b005428f77efecsi1745309pga.749.2023.06.10.09.33.51; Sat, 10 Jun 2023 09:34: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=@wanadoo.fr header.s=t20230301 header.b="YY/e99Cu"; 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 S235799AbjFJP7x (ORCPT + 99 others); Sat, 10 Jun 2023 11:59:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235723AbjFJP7r (ORCPT ); Sat, 10 Jun 2023 11:59:47 -0400 Received: from smtp.smtpout.orange.fr (smtp-13.smtpout.orange.fr [80.12.242.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3047230D6 for ; Sat, 10 Jun 2023 08:59:45 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id 80zwqFULNV4eY810CqBQ6F; Sat, 10 Jun 2023 17:59:44 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1686412784; bh=x5Q7JFOBqrMC6o8LYzgUOOfoq0P2ZHbeu6tRAx/Ruf8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=YY/e99CuaAkuIPwh6/SwneGP1bgOzZ4odMId2zpnEkjSh3cZgft7aYxVRg6Wnj3Qr hoAVzpPPXUhZ4doPh2Nf4+hQUrE01Ce/6zSCNAiKs8HMFrxxsP3bZWmqwx9+378vXp fRqwQHcYiJ3v+WlDVbhROmisSkW5xwLzjf5w0F8enIwvJjpm5mvRPzCwUnYZC6pAav FUMjzRH6n00FqPIoVyf67rr1tF0+nIXXxSnP2kCXbLHlUpcBKCl02JWpzHU+EsMhkD jwVgmjma1/1IKVYO1C+ZbRdUX2XhcVVRqisluDxYBfB83SJvP8Atgi95U5FstO/v/5 LYkv4i5LVGZHw== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 10 Jun 2023 17:59:44 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Krzysztof Kozlowski , Alim Akhtar , Greg Kroah-Hartman , Jiri Slaby Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , Walter Harms , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-serial@vger.kernel.org Subject: [PATCH v2 3/3] tty: serial: samsung_tty: Use abs() to simplify some code Date: Sat, 10 Jun 2023 17:59:27 +0200 Message-Id: <7bd165e82ed3675d4ddee343ab373031e995a126.1686412569.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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?1768333846203093785?= X-GMAIL-MSGID: =?utf-8?q?1768334131927322772?= Use abs() instead of hand-writing it. Suggested-by: Walter Harms Signed-off-by: Christophe JAILLET Reviewed-by: Jiri Slaby --- v2: new patch --- drivers/tty/serial/samsung_tty.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c index 0b37019820b4..b29e9dfd81a6 100644 --- a/drivers/tty/serial/samsung_tty.c +++ b/drivers/tty/serial/samsung_tty.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -1485,9 +1486,7 @@ static unsigned int s3c24xx_serial_getclk(struct s3c24xx_uart_port *ourport, } quot--; - calc_deviation = req_baud - baud; - if (calc_deviation < 0) - calc_deviation = -calc_deviation; + calc_deviation = abs(req_baud - baud); if (calc_deviation < deviation) { /*