Received: by 2002:ab2:3c46:0:b0:1f5:f2ab:c469 with SMTP id x6csp281472lqf; Fri, 26 Apr 2024 06:41:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWYhrWr5cR5VpVpTkz5/wE4ssGygTQPtKhQpW/c49i5FO+gGgvF+X3xUBxvsxC86u3DpJf1qJzcoiO3kneXguswmN4nXhtH/8MPvVPHcg== X-Google-Smtp-Source: AGHT+IEDNMvANK+Jbhb9m1Nph8Wv5MgedTqpseKgxdpa5MBcQArBpKvxKn329dexUorcB22TN+mP X-Received: by 2002:a05:6122:1817:b0:4d4:17c5:8605 with SMTP id ay23-20020a056122181700b004d417c58605mr2622865vkb.7.1714138896041; Fri, 26 Apr 2024 06:41:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714138896; cv=pass; d=google.com; s=arc-20160816; b=avdqsnfFNutrWMfRAU/V0Z9ma8CTH1Q6uVzrn8z4Nle9CbWfoFj2SBPYug65cxPHGP 6vwMq6mu//0LUuvc63K+jS3byhjKvsbpBxmQ8x7Mkxm7X2BJLnRFddMmhlY2vdpwVtjP CA9ur1fHqd5qiw0FOYdgCMOJvZ0KqIemljymBtuvFtJ7DTrYYrigvxdlyX82OkffIOWV rbE7t7x3gM8DJLh3nBgABq+TsVmQc7Ho+TfCY0CTdGHjHP6rsN5QUhNXi5rBvYHjdZW3 4uXwFhtwNtKN3wc91sxOgxpQXZ+tXVT4PjpT4dqT6F1Ayk+1Lm8YYXSYn+xFKcHMIsR5 +DRg== 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=AocrA75mqcRUL0QWSUoM3dEaQjCJ8gV8EQHfgGHvBrE=; fh=8Nlnw8rZTa/GTwXg7npKBtk/r65cOvRu6zvZEllri9c=; b=YfwQ+CCS0sFKLznofrV/84Gypvo5ww1m+IU/h7tbq5Jlk3uDQjGc5KXPfNfcchZuqK HuIRPiKj41tqEzZGpvsVwsMjvp2GWVYKBdbv7GpKIhR0yNlGXM3WQkSa/KmyroufH7zn zA0VEzmflUVgRW8N5JswEFwmJAkbsSJQsP8noVEzLUQyLOI4Qvm1v2OyL2LcBcidvn1Q ZBZvlrcP6zeVw/4jR+iHYBLxq/fGHoPKLkxyacOu5sbG343TFb7j+0cxi8U4Xmc4i+jM jYpY9aeR5+vhGTMHFjGwXh3oCjTsNmuLsa4odLAY1rPgYihn20WMeeag7CWyEcCdxUMa 97NQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b=kMhA+QR7; 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-160074-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160074-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=126.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id j34-20020a056122092200b004daa94b5852si3850074vka.173.2024.04.26.06.41.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 06:41:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-160074-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b=kMhA+QR7; 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-160074-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160074-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B96801C23767 for ; Fri, 26 Apr 2024 13:41:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9DD2614830C; Fri, 26 Apr 2024 13:41:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=126.com header.i=@126.com header.b="kMhA+QR7" Received: from m16.mail.126.com (m16.mail.126.com [117.135.210.7]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6880D147C95; Fri, 26 Apr 2024 13:41:08 +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=1714138871; cv=none; b=g+jBfQ1iydTBX/kLJsabMPmuZ/43AxUIDrZ8G9Xd5xehiV94xNuBtlGk7YfkhenENRHNr1mIl/GWuiCkyp80hDenj9Stgts97P914uIS5biAoLsLGUERrivcLdE+CN0rciVpTXiaEqYQuEF2Z+52ic2aNm6cO0T+PFyTCGI36ao= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714138871; c=relaxed/simple; bh=UXjzwyHD3xU06AXyGFYmDxIwYgvujORr2saZ8aiLHQY=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=QiRRV3nWMSz3QGHiq9cc0iAW3jafI5MpR4MYfVMMsolJbEBp52i824GBp8OolV9VhTjp5UEuCpF9G6P/4NUkW0+3dun7p3jQDMoat+KrcSfRnVSWvrm/ICKlYCiERcdgq6XfQHBgO8DMeGPMsiL2fobg5PnOXXCOcdQ/peJ2Nw8= 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=kMhA+QR7; 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=AocrA 75mqcRUL0QWSUoM3dEaQjCJ8gV8EQHfgGHvBrE=; b=kMhA+QR7pv2AWw5e3Q7yi qXUpN6oisGUAxmMLrGJZYlPua9etZBOrZpzTVLDhAwsgUUnRG1ueNKZGhLG/uMtD gQKwCT8VwpjRXTDiGLxQUnY7DM1jAftB/rif5mC0Kb9NtNL9Wni6nHijgc/t+Og4 elXEy4XbmvMNUB560Q7anc= Received: from localhost.localdomain (unknown [111.198.54.11]) by gzga-smtp-mta-g1-5 (Coremail) with SMTP id _____wDnL5KwritmM0DuBQ--.25861S2; Fri, 26 Apr 2024 21:40:01 +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.or, LuMingYin Subject: [PATCH] serial: 8250_lpss: Fix memory leak in lpss8250_probe() Date: Fri, 26 Apr 2024 14:39:59 +0100 Message-Id: <20240426133959.1294012-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:_____wDnL5KwritmM0DuBQ--.25861S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7KryfAFW5WF1UJFW8GF4fuFg_yoW8XFWDpF s0kFsIkFy0q3WIga40yr4jqF15uFWxX347CrZrC3sI9rZIyF97tF1ftFy7tF10grWktFnF ya1UtF45Ca4UXFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07js0edUUUUU= X-CM-SenderInfo: poxpx0hj1l0vphwhu3a6rslhhfrp/1tbiEBXM9mVLbFpVzQAAs- From: LuMingYin The return statements at line 347 and line 351 in the lpss8250_probe() function result in a memory leak of the variable pdev. Add a label named free_irq_vectors in the lpss8250_probe() function to release the memory area pointed to by pdev. Modify the two return statements mentioned above to jump to the label "free_irq_vectors" instead. Fixes: e88c4cfcb7b888ac374916806f86c17d8ecaeb67 ("serial: 8250_lpss: fix memory in lpss8250_probe()") Signed-off-by: LuMingYin --- 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