hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/tty/serial/samsung_tty.c
....@@ -1313,8 +1313,12 @@
13131313 continue;
13141314
13151315 rate = clk_get_rate(clk);
1316
- if (!rate)
1316
+ if (!rate) {
1317
+ dev_err(ourport->port.dev,
1318
+ "Failed to get clock rate for %s.\n", clkname);
1319
+ clk_put(clk);
13171320 continue;
1321
+ }
13181322
13191323 if (ourport->info->has_divslot) {
13201324 unsigned long div = rate / req_baud;
....@@ -1340,10 +1344,18 @@
13401344 calc_deviation = -calc_deviation;
13411345
13421346 if (calc_deviation < deviation) {
1347
+ /*
1348
+ * If we find a better clk, release the previous one, if
1349
+ * any.
1350
+ */
1351
+ if (!IS_ERR(*best_clk))
1352
+ clk_put(*best_clk);
13431353 *best_clk = clk;
13441354 best_quot = quot;
13451355 *clk_num = cnt;
13461356 deviation = calc_deviation;
1357
+ } else {
1358
+ clk_put(clk);
13471359 }
13481360 }
13491361