Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2490060lqp; Sun, 24 Mar 2024 23:18:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXi6egh6DvuWDgGQhmIiyvFGHtPfusQYRxTEJ+ZAAVvdeHDYUpLuuljgC3P1Ok/Qapb8/J1kuoMTH29AlVLY0G6hL3W6AHR3eO0KbnNng== X-Google-Smtp-Source: AGHT+IEtKmPN0OubMWMCUr42S1DYSzm+Zm8mZ++Eg4vCwvbhby4iT4ZZ1oD5sIlN85Xk0Ye1f1Mz X-Received: by 2002:a05:6358:590b:b0:17f:8831:21b4 with SMTP id g11-20020a056358590b00b0017f883121b4mr1184456rwf.23.1711347481172; Sun, 24 Mar 2024 23:18:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711347481; cv=pass; d=google.com; s=arc-20160816; b=NcU5RaXYj0kpHOVEMnfC1PrmRLGMHcFinDm1N6vPnGlmhj0ypsYZ1DtQG7Wny/mnXO NwwSk/LsYMqiniHEnHO+nHxMqgPbLeNlZbSTM9hSuxpXBxWjEWDAMa2sLrRsZp6VeJg/ 5T+I27FxfmsA/USYp+j7iwgYpnp7yD+DgAjLiQjXBJStfiBVFQOSv1++tSN5B4E1/grx JldNC4KaRJj4v6i24d/YRffpulSHGoI5LBqTesQY+ZWBAy2CeHsEXcc1InTxZsb616Ay G14VrUdtm7ao6kAzy5MscrETTUPVhlUr4Mdu0BGLiuGhoIMMuB5FeSYTcTDBvCtSXTqY L6Bg== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=7NAaqU3OvMfJytH/ikXpfcnrN4d6R80uqSJunxEoPEY=; fh=bZoRrUF/pSxDv85xCSbCy2WqeGAA3D5Lk94umepTZGI=; b=UhfV6Qyzxav8LkFWKqp7eTnUZ/M27VrkBxlphcsz1Ks09TMJxWuqzreFo0Ai7Wtdep LDyYSPg3DaNSdm/m9UAb59nlMYjGv0W6vJuO6xI1MAvQ4GnnQxdyn18OHfTKPvdBDY/y 4QC8UJk4tYFq6uhlqIs6BrBPtWMuD8kmN2XxHIuMGHXz85pFbQpZJA9QrRE1i4Ow2uMa z6AfjmmA+sXGHXuaBsVLD5yz3tHrtiKHkv1UL09kv54mzJGVFCxzkP2S0Vwn9HN+zMXC af98FnLHJvSzaN8oSAr9Txt0fjZb5FT0R/vLgTFj85+jRc28YiE+WlA7aYRv1MNVdUoX qjIg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JgBwFWEF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-114572-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-114572-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q17-20020a635c11000000b005d8bc1d9b5esi7060230pgb.313.2024.03.24.23.18.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 23:18:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-114572-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JgBwFWEF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-114572-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-114572-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 328A728DC5D for ; Mon, 25 Mar 2024 06:17:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 78561185F04; Sun, 24 Mar 2024 23:53:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JgBwFWEF" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C59A22F8D5; Sun, 24 Mar 2024 23:16:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711322215; cv=none; b=UTAF1AnmosptfNQMwuAX7EMvk+0KwxIHEkJpUOYaJkariJ+dFV91jigVL5R1FdYSKXTeKknWIIgu5O7dAMsL3eKHUOM6z75vRllW/GitFTki09CwITWhjaM6zknE2WA5HlW/ubANz7SgoyJH2MjwnQZQxeype2ba8rBNqk4lSGM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711322215; c=relaxed/simple; bh=6/TKhYAWFLjY1q5mVhCWhWF3ca2KGgT9UOud7UTcL94=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OLfMxX5WKQ6EVy7Eo+NeYsAtb1LqJ7q6M3beQ26hflzV9bMGBafCKSoOuT2Wp7RlKbuvCbioFQvTe8CylaFrTAEky+hgmgm0CpUmqHUR9v/NrasNposCg31ACbjUgxHqdb6D0RM1o8UQPZnbYCX8S88Cw13Dk7FX4frU4ReDDWI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JgBwFWEF; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9400C433C7; Sun, 24 Mar 2024 23:16:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711322214; bh=6/TKhYAWFLjY1q5mVhCWhWF3ca2KGgT9UOud7UTcL94=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JgBwFWEFtQ7I58mLgmVHeoSRUP+uoUe6NTypo1I1l56zslx5yUFPfPOxPhtkjSvwF 0jFarhfgenYH5xKF3DUsCWarcOuvIUk8dedCZQWQ2gMMMq9k5ATQuGBZNyM3C7g3Ba 9fqhxh7eVRzHjI9ZpCL/EhuQxOvZUiCxc0VfGGvvpfUkWyDEn0lo6KF/p/GC6JuHtT lcIr35ARIbtbdolNN15oBXBs/UiNc/A/FakJKTGeXJiKQiJ9d2PY5IlUiloH5Dd78U Zbyt4i5FFl8glWqHNJp4C+dTlWLmiJNmxbpLPavFEjH6kBseQZAxcRkOeshs3bFGtC t9N0NxZXtn8Cw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: ruanjinjie , Jon Mason , Sasha Levin Subject: [PATCH 6.1 294/451] NTB: EPF: fix possible memory leak in pci_vntb_probe() Date: Sun, 24 Mar 2024 19:09:30 -0400 Message-ID: <20240324231207.1351418-295-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324231207.1351418-1-sashal@kernel.org> References: <20240324231207.1351418-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: ruanjinjie [ Upstream commit 956578e3d397e00d6254dc7b5194d28587f98518 ] As ntb_register_device() don't handle error of device_register(), if ntb_register_device() returns error in pci_vntb_probe(), name of kobject which is allocated in dev_set_name() called in device_add() is leaked. As comment of device_add() says, it should call put_device() to drop the reference count that was set in device_initialize() when it fails, so the name can be freed in kobject_cleanup(). Signed-off-by: ruanjinjie Signed-off-by: Jon Mason Stable-dep-of: aebfdfe39b93 ("NTB: fix possible name leak in ntb_register_device()") Signed-off-by: Sasha Levin --- drivers/pci/endpoint/functions/pci-epf-vntb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c index 8c6931210ac4d..cd985a41c8d65 100644 --- a/drivers/pci/endpoint/functions/pci-epf-vntb.c +++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c @@ -1288,6 +1288,7 @@ static int pci_vntb_probe(struct pci_dev *pdev, const struct pci_device_id *id) return 0; err_register_dev: + put_device(&ndev->ntb.dev); return -EINVAL; } -- 2.43.0