Received: by 2002:ab2:3c46:0:b0:1f5:f2ab:c469 with SMTP id x6csp212542lqf; Fri, 26 Apr 2024 04:49:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX1uYd5mQZB/E9m0LBqy7f7+UzqrF3zEK6ejlr/7CjIAOg11W+SLMdIV/oP3YhNS1lltlmuzDgQAaORT1QMZgBQBExZJs+dqqxYug6bGA== X-Google-Smtp-Source: AGHT+IFA96W6cBTCa8WoqRtUp/czImmEHUx8a6suzl5jMx1cuPXPatwMeCh0sVGrMxItz0fqcyc3 X-Received: by 2002:a50:d4ce:0:b0:570:392:aa1a with SMTP id e14-20020a50d4ce000000b005700392aa1amr2299640edj.7.1714132143755; Fri, 26 Apr 2024 04:49:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714132143; cv=pass; d=google.com; s=arc-20160816; b=fnvnS2w69P/hSvHnTqgxn3YHkhDFW4evtiWzwyBufmr7IOIIPwp/u86T9LPkiV1L5A l/ku6IieVbSrKAhiRM1wwlYuEyi21jQARrPJgDvEvWdhINiEpZoEs+bKPmQE9ZMM/PCw SLYPQOYMkzcIP+DTn3UZRAcvuf0czm5je5U0eHJBUyENkW0VyCM/fHL/TpjxuL3V2e64 mHv8WOOLyqAfPYR6RNIJpo2HF585MHtaCBxu5PvtBT9J8N08/fvmzA94Nii4l3ofvzWt bBXwKihsOJ2TqsaORTC5FmrUgB5ZDkWr+oTPVDEl/XXyj3p5WjHt1psCT/KO9r0+C3z/ Q8ew== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=6MWsSmdYALQgj2DpgEGwlSeW/uW9ibfcAZbE4CpfAhE=; fh=KUZSexWo0TEbkAFVsCpx/6m6nmUhPOs2V/K5xGN4rLU=; b=fEf8NbilgH8R7oArO0Vk+BROsqYdjiZsVhHDBIr/R8SDnbuJP9RuUSOINrPEZ6DnIb QKclis/M8mAlahZKRI0pfffyLCPF+mjqaAmwhfCEkxAZTt2+xBW8GvzjSmRHxiu++6l7 e3C1cVh7/J8o0iqwhR99KhWWUzk80Ve3ovJt/86LuMI0lD36/HYS6AdGwJgWCZF+q9Sf r+VfHZGxNtAVgJ/6VLm9NYBC742dvaVQ/udxKl0NCf1WFNKWgn9NqaMJv3U1HU+zcp36 eBs1UcV3c0eQpVd/M9lyuFQM/VJOoZ+QSGgl8rq8bcpy2qeqKveSOcmOY0SKsvzBtFUD PBqw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b=bTqjKFnl; arc=pass (i=1 spf=pass spfdomain=126.com dkim=pass dkdomain=126.com dmarc=pass fromdomain=126.com); spf=pass (google.com: domain of linux-kernel+bounces-159952-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159952-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=126.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id v10-20020aa7d80a000000b0056bb595c538si10636481edq.462.2024.04.26.04.49.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 04:49:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-159952-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b=bTqjKFnl; arc=pass (i=1 spf=pass spfdomain=126.com dkim=pass dkdomain=126.com dmarc=pass fromdomain=126.com); spf=pass (google.com: domain of linux-kernel+bounces-159952-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159952-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=126.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 7CA621F21FB2 for ; Fri, 26 Apr 2024 11:49:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 25D76145B1C; Fri, 26 Apr 2024 11:48:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=126.com header.i=@126.com header.b="bTqjKFnl" Received: from m16.mail.126.com (m16.mail.126.com [117.135.210.7]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D69DC14533F; Fri, 26 Apr 2024 11:48:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714132129; cv=none; b=WWhMHRqQHVS7o/onLywucVsOPEUW8t14tQDKSla1uBlKabwFUz2pJTMuik/ahb1g+B8e51wB4CxL09UDXlsgBfhKze4ZmLXDQxC8JUFfcpCqTc2eUYrqxjV0t8fJ3bmUma9zPdnsDC/Q0+d3l2B2gGfsxQAgBWKtI7r6/MFvsIk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714132129; c=relaxed/simple; bh=/SN/zjSnuky3OM1kz6zYORox+mvKrXnMtsKEX2ub648=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=dJJnq4s0RUWdDg/5iOgKlLIw8XnCfXPaeG4zN5Mi3DSPsP91PtNp6jcZd+Qz/HflkdAYeTC8AoWSVxFDrykVDJfrQM9WrrxkKhL3eITEmVl2IEX6OuyGF4FXJRhv08atW6hmbNKUHjF8wKKZVHjt8pXC5QP2tNXZEYcXUmKJThg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=126.com; spf=pass smtp.mailfrom=126.com; dkim=pass (1024-bit key) header.d=126.com header.i=@126.com header.b=bTqjKFnl; arc=none smtp.client-ip=117.135.210.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=126.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=126.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=6MWsS mdYALQgj2DpgEGwlSeW/uW9ibfcAZbE4CpfAhE=; b=bTqjKFnlbpEgmyGJD3kez tEyy0qG8mJmp4HY0TM6auVKvLRAhvE3bp+WTpY4CLNP/NvHvxYjbxDX78/zN+Va8 Wouq83fnBygu0yRrLYx0dMftaFio5GXshrbyX6CsxB2BT8Zclkr87AK9EwGKj4j8 n15ny4dZl0VkbN0rNBj1AU= Received: from localhost.localdomain (unknown [111.198.54.11]) by gzga-smtp-mta-g1-0 (Coremail) with SMTP id _____wD3f2tGlCtmh+bjBQ--.51640S2; Fri, 26 Apr 2024 19:47:19 +0800 (CST) From: lumingyindetect@126.com To: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Cc: ilpo.jarvinen@linux.intel.com, andriy.shevchenko@linux.intel.com, gregkh@linuxfoundation.org, jirislaby@kernel.org, LuMingYin <11570291+yin-luming@user.noreply.gitee.com> Subject: [PATCH] serial: 8250_lpss: Fix memory leak in lpss8250_probe() Date: Fri, 26 Apr 2024 12:47:16 +0100 Message-Id: <20240426114716.1275085-1-lumingyindetect@126.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:_____wD3f2tGlCtmh+bjBQ--.51640S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7Cw45Zr15XFW8CF45tw43Jrb_yoW8Aw1DpF s0kF9IyFyFqFy2gw1UAr4qqr1rAFZ7Xa47CrZrK3sI9FZFyFn3tFn3t34SyF18XrZ5tFy2 va1jyF45Aa4UJaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07bbJ5rUUUUU= X-CM-SenderInfo: poxpx0hj1l0vphwhu3a6rslhhfrp/1tbiEAfM9mVLbFgvQQABsY From: LuMingYin <11570291+yin-luming@user.noreply.gitee.com> In the execution logic of the lpss8250_probe() function, the function may directly return via a return statement at either line 347 or line 351. Unlike lines 357 or 361, where the return statement is used directly without releasing the dynamically allocated memory region pointed to by the variable pdev, causing a memory leak of the variable pdev. In the lpss8250_probe() function, I added a label named "free_irq_vectors" to release the dynamically allocated memory region pointed to by the variable pdev, and replaced the two return statements mentioned above with goto statements to this label. Fixes: e88c4cfcb7b888ac374916806f86c17d8ecaeb67 Signed-off-by: LuMingYin <11570291+yin-luming@user.noreply.gitee.com> --- drivers/tty/serial/8250/8250_lpss.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/8250/8250_lpss.c b/drivers/tty/serial/8250/8250_lpss.c index c3cd6cb9ac80..fa9fd4dc86c7 100644 --- a/drivers/tty/serial/8250/8250_lpss.c +++ b/drivers/tty/serial/8250/8250_lpss.c @@ -344,11 +344,11 @@ static int lpss8250_probe(struct pci_dev *pdev, const struct pci_device_id *id) uart.port.mapbase = pci_resource_start(pdev, 0); uart.port.membase = pcim_iomap(pdev, 0, 0); if (!uart.port.membase) - return -ENOMEM; + goto free_irq_vectors; ret = lpss->board->setup(lpss, &uart.port); if (ret) - return ret; + goto free_irq_vectors; dw8250_setup_port(&uart.port); @@ -367,6 +367,7 @@ static int lpss8250_probe(struct pci_dev *pdev, const struct pci_device_id *id) err_exit: lpss->board->exit(lpss); +free_irq_vectors: pci_free_irq_vectors(pdev); return ret; } -- 2.25.1