From nobody Mon Jun 8 04:25:58 2026 Received: from va-1-111.ptr.blmpb.com (va-1-111.ptr.blmpb.com [209.127.230.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFB7C2765DF for ; Tue, 2 Jun 2026 12:45:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.127.230.111 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780404346; cv=none; b=MBt0Ba4xTIb5JVCR+lZizLFN6Sqh2Uwnr2ipzr0sWER5X9DynEyHwa88iEF24qMs/LCEC9pz9Rct7uNmx/M8rkoJ6rQrPJAA3MPMFyzvLm5AsxoS944PEmx1Ix9q3V3XJ8JaoFgZNTabgBt0zBhdK6RgEdQXNV7TFqwyfLD+P24= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780404346; c=relaxed/simple; bh=Sld+qUyKjabJ0waQJgZNH1xr6cbEUSm4u2piF2phkvw=; h=Cc:Message-Id:Mime-Version:Content-Type:From:Subject:Date:To; b=pkF023UAZsrx0Vvox9qmgn7qFUfFki3o+wIShnGcGAGNCjd8mFZ7zXEHmWpm9wRHXnkRwN3hYI8wnZX1xWD0qpENt675Asanyv4zKEHzwsPWfDC5Ut0XCnrgBbaDTlVFY9pflEzIo4HaJRMBeGab0Tf+DcuYVD2WruqbhUNlerc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=eMiPIhdZ; arc=none smtp.client-ip=209.127.230.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="eMiPIhdZ" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1780404333; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=Db0pcyHB9iqs3Kuiw/HVa/1tfeH0BZGlXBcrSVMEodg=; b=eMiPIhdZ6mSX7p8D28/OjBkR2fs7zepSFTVdLvprVhPRMey7C01dOD0dRsC/fC3yueMB2F DUmz4D7HBquLyK1xOlo+nI5TmxjIQxLd3Wkf17sCYZ2tdjw9Q/BeZtEN52CauxULSYwgvq T+y7hRH7/GcPiW1iwUPsx8NWjbNdyhKSFJ2fmzCgP4T8fror8XuEgSqfg2CYjYpkqyyJBN hpEAEbTq4mPOLW0lHzELEtOEcId1o1jPqhIUbj1xPKKTARYaMqbTb3mPG1dWRSfGNI5Jj0 f/LDJTdMke/E34zPkg+QccYnC9RBDcdeF9RqfjBzvMeYnhtX7zS6YYZ/5+JHAA== X-Mailer: git-send-email 2.20.1 Cc: , , , , , "Rui Qi" Message-Id: <20260602124509.365996-1-qirui.001@bytedance.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: "Rui Qi" Subject: [PATCH] selftests/livepatch: fix resource leak in test_klp_syscall init error path Date: Tue, 2 Jun 2026 20:45:09 +0800 To: , , , X-Original-From: Rui Qi X-Lms-Return-Path: Content-Type: text/plain; charset="utf-8" In livepatch_init(), if klp_enable_patch() fails, the previously created kobject and sysfs file are never cleaned up, causing a resource leak. Capture the return value and add proper cleanup on the error path. Signed-off-by: Rui Qi --- .../selftests/livepatch/test_modules/test_klp_syscall.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/livepatch/test_modules/test_klp_syscal= l.c b/tools/testing/selftests/livepatch/test_modules/test_klp_syscall.c index 0630ffd9d9a1..d631acae48b9 100644 --- a/tools/testing/selftests/livepatch/test_modules/test_klp_syscall.c +++ b/tools/testing/selftests/livepatch/test_modules/test_klp_syscall.c @@ -109,7 +109,12 @@ static int livepatch_init(void) */ npids =3D npids_pending; =20 - return klp_enable_patch(&patch); + ret =3D klp_enable_patch(&patch); + if (ret) { + sysfs_remove_file(klp_kobj, &klp_attr.attr); + kobject_put(klp_kobj); + } + return ret; } =20 static void livepatch_exit(void) --=20 2.20.1