From nobody Fri Oct 2 01:56:58 2026 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 47E663BCD16 for ; Thu, 6 Aug 2026 07:04:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785999852; cv=none; b=sd+LySUN+qakJvbnYm0i1H3u+9LTUNR2NXYsYwOAf0o0o/B4AzAnf9RgPfH2AFNS7N/CO+mEsWQU0Mykx3lZ8u4AF3WeXA+MfjWUWSXI6FwwALyZHXb43pWpeiy/ETM+sQs0o/PoiCqZ9bREyMtKuV8mvj8D8D6Fw5IONCdYc8g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785999852; c=relaxed/simple; bh=9M9Dn+a1WSLmYDLusF8+3JGfsR2CjQ+Ph/QRzPTaNhM=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=tDwARQcqZ6amvuV5cO+1XTCbyGUseW3dRC5WrOpbs/MZmH7OzvMaXS2Y4ihPIHPQCpTRxqccTh8yjm/VhZryXzlYzZRKNnba9KtqSWcjw61PhUl0v34v+Y04X22575bQYoQhACPH+iKppAylNTuH9bLDWoEh48KaJJ8NgeuW6pY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 01dc6c4e916511f1aa26b74ffac11d73-20260806 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.12,REQID:592a90f5-5e5d-4a21-a7cd-5152056f57b7,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:e7bac3a,CLOUDID:b3d305cf7d80c8e89faf3234f68b1dcc,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:102|136|850|865|898,TC:nil,Content:0|15| 50,EDM:-3|-100,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0, OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 01dc6c4e916511f1aa26b74ffac11d73-20260806 X-User: gonglinkai@kylinos.cn Received: from localhost.localdomain [(10.44.16.150)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256) with ESMTP id 233961360; Thu, 06 Aug 2026 15:04:03 +0800 From: Linkai Gong To: Arnd Bergmann , Greg Kroah-Hartman Cc: James Bottomley , linux-kernel@vger.kernel.org, Linkai Gong Subject: [PATCH] misc: enclosure: fix UAF on device_register() failure Date: Thu, 6 Aug 2026 15:03:58 +0800 Message-Id: <20260806070358.1599627-1-gonglinkai@kylinos.cn> 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: quoted-printable Content-Type: text/plain; charset="utf-8" After device_register() fails, the embedded struct device has already been initialized and must be released with put_device() so that enclosure_release() can drop the parent reference and free edev. The error path currently does put_device(parent) + kfree(edev), which skips the device lifetime rules and can free the object while the device core still owns a reference (use-after-free). Fixes: d569d5bb3fd9 ("[SCSI] enclosure: add support for enclosure services") Signed-off-by: Linkai Gong --- drivers/misc/enclosure.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c index cf6382981777..7e3887b646ad 100644 --- a/drivers/misc/enclosure.c +++ b/drivers/misc/enclosure.c @@ -148,8 +148,7 @@ enclosure_register(struct device *dev, const char *name= , int components, return edev; =20 err: - put_device(edev->edev.parent); - kfree(edev); + put_device(&edev->edev); return ERR_PTR(err); } EXPORT_SYMBOL_GPL(enclosure_register); --=20 2.25.1