Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1314590ybt; Sat, 27 Jun 2020 04:46:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyagT0dLMUtTBejrC9GCYGHqGZ9Th3wwEZ4CxCaYelCpQZj8DcZ9KncIvuqCd1GXv4gHBl9 X-Received: by 2002:aa7:c407:: with SMTP id j7mr8045431edq.96.1593258412094; Sat, 27 Jun 2020 04:46:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593258412; cv=none; d=google.com; s=arc-20160816; b=Hz2LQ0KizjQ5r2RL4BJOI7N0sciJ1kH5pb9wHuV6RZmh8Y009OljQqQJjKoivArEGG IwPZqcRE480QJeS6ILVm4P21AA3egg3XyRc2NGo4aXjNPdNC8kUgsF9lYwqAgouJZekz VbZegElObR8aNwWbARQWvVjHW3tx5bSKwWbO0qSJovPDWqDArsIsVmkPfCmhQKGnJ2kk mMj3uJBDIvObxqd59EHHxY5BJtIHp+/sjwfUtVXoxC35Nxoc1iQfVq4z9gQYb879pnt2 5BTW7/g3Pe8saDBylYIx/3De0RuL5GlmBXJb9577mq/RCARXtxURfKX/bPxqZRHfnzsr ov/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ITl1Pz8QJlvZMKyBVX40Sy0voYKC/77C4J4mKkwaOC4=; b=i7SGUCIMR5ZU6Jb6ZYBL0NnZ/OTUgJQz3gbmI5jRrz2EhWxWqO8aoUF7px6L11cqjv E2PNpD9jeF7eSnilKxr8xlnNRhi5jD9it0ZWdFsLa7Rxe3irFGHiy4W+9ihbsd/DStn3 iXQIOFDj2SQ6JRDzYaEbVNrLtVw8SaaztdAegXwNCBdgPaLExM73rC4bBoGiZp468crN YtRKwcC/MzWqA5ModgjLgLRae3V/p5azezc01Z+XBFk24iWn/8WJBC7IYtp8MzBcOxTV VSUQL4b4dqObsBkuDkEj/S3gAOoCpm8yZ3Emv7wkPa7yB6wPXwWOECBLbwPRRQReQ/mm k3RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="ZUyy6/58"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u25si14312983ejr.632.2020.06.27.04.46.29; Sat, 27 Jun 2020 04:46:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="ZUyy6/58"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726569AbgF0Lnb (ORCPT + 99 others); Sat, 27 Jun 2020 07:43:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:57546 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725980AbgF0Lnb (ORCPT ); Sat, 27 Jun 2020 07:43:31 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 00E1F2168B; Sat, 27 Jun 2020 11:43:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593258210; bh=luIbcfQ9AtgqmqpM9hXBQ4Dyo3o9hQW+jfI/EipCS8E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZUyy6/58KAgvEA0zYlPzS9GLC+9nsuaVuYjq5jCEbel/yq9PCRgeqHqk+VgiI6sDE bImsDyg9wdH8sceZAU8jyaPJufZ4Lml3H12NJwzsDwLJyoo7yWYiGrIEr0rdPBVQyA GCtRYSlyLCrMy7KlZJ0A1waDDjIsl5b1IBxpwzkw= Date: Sat, 27 Jun 2020 13:43:23 +0200 From: Greg Kroah-Hartman To: Jiri Slaby Cc: Xiyu Yang , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, yuanxzhang@fudan.edu.cn, kjlu@umn.edu, Xin Tan Subject: Re: [PATCH] tty: serial_core: Fix uart_state refcnt leak when the port startup Message-ID: <20200627114323.GA1645692@kroah.com> References: <1592052738-95202-1-git-send-email-xiyuyang19@fudan.edu.cn> <20200624093407.GB1751086@kroah.com> <954840f0-2078-fe0f-1e52-d985a4997564@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <954840f0-2078-fe0f-1e52-d985a4997564@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 24, 2020 at 11:42:59AM +0200, Jiri Slaby wrote: > On 24. 06. 20, 11:34, Greg Kroah-Hartman wrote: > > On Sat, Jun 13, 2020 at 08:52:18PM +0800, Xiyu Yang wrote: > >> uart_port_startup() invokes uart_port_lock(), which returns a reference > >> of the uart_port object if increases the refcount of the uart_state > >> object successfully or returns NULL if fails. > >> > >> However, uart_port_startup() don't take the return value of > >> uart_port_lock() as the new uart_port object to "uport" and use the old > >> "uport" instead to balance refcount in uart_port_unlock(), which may > >> cause a redundant decrement of refcount occurred when the new "uport" > >> equals to NULL and then cause a potential memory leak. > >> > >> Fix this issue by update the "uport" object to the return value of > >> uart_port_lock() when invoking uart_port_lock(). > >> > >> Signed-off-by: Xiyu Yang > >> Signed-off-by: Xin Tan > >> --- > >> drivers/tty/serial/serial_core.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c > >> index 57840cf90388..968fd619aec0 100644 > >> --- a/drivers/tty/serial/serial_core.c > >> +++ b/drivers/tty/serial/serial_core.c > >> @@ -205,7 +205,7 @@ static int uart_port_startup(struct tty_struct *tty, struct uart_state *state, > >> if (!page) > >> return -ENOMEM; > >> > >> - uart_port_lock(state, flags); > >> + uport = uart_port_lock(state, flags); > > > > How is this a different pointer than you originally had? > > Was this patch sent twice? As I had very same questions on the other > one, but never received a feedback: > https://lore.kernel.org/linux-serial/bf6c1e7b-3dc6-aba6-955a-fee351a6d800@suse.com/ > > > Oh, wait: this is uart_port_startup, I commented on the uart_shutdown > one. But whatever, I would scratch both of them. Yeah, you are right, dropping them both now, thanks. greg k-h