Commit 5db2347
committed
nvme: host: fix double-free of struct nvme_id_ns in ns_update_nuse()
JIRA: https://issues.redhat.com/browse/RHEL-25547
When nvme_identify_ns() fails, it frees the pointer to the struct
nvme_id_ns before it returns. However, ns_update_nuse() calls kfree()
for the pointer even when nvme_identify_ns() fails. This results in
KASAN double-free, which was observed with blktests nvme/045 with
proposed patches [1] on the kernel v6.8-rc7. Fix the double-free by
skipping kfree() when nvme_identify_ns() fails.
Link: https://lore.kernel.org/linux-block/20240304161303.19681-1-dwagner@suse.de/ [1]
Fixes: a1a825a ("nvme: add csi, ms and nuse to sysfs")
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
(cherry picked from commit 8d0d244)
Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>1 parent cac3477 commit 5db2347
1 file changed
+2
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | | - | |
| 224 | + | |
225 | 225 | | |
226 | 226 | | |
227 | | - | |
228 | | - | |
229 | 227 | | |
230 | | - | |
231 | | - | |
| 228 | + | |
232 | 229 | | |
233 | 230 | | |
234 | 231 | | |
| |||
0 commit comments