[PATCH] ceph: fix potential ERR_PTR dereference in ceph_submit_write()

From: Hongling Zeng

Date: Fri Apr 17 2026 - 04:11:28 EST


Fix smatch warning:
fs/ceph/addr.c:1489 ceph_submit_write() error: 'req' dereferencing possible ERR_PTR()

Add a check to ensure req is not an ERR_PTR before calling
ceph_osdc_put_request().

Fixes: 1551ec61dc55 ("ceph: improve error handling in writeback")
Signed-off-by: Hongling Zeng <zenghongling@xxxxxxxxxx>
---
fs/ceph/addr.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index fa4f25f99409..6091818674be 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -1468,7 +1468,8 @@ int ceph_submit_write(struct address_space *mapping,
unlock_page(page);
}

- ceph_osdc_put_request(req);
+ if (!IS_ERR(req))
+ ceph_osdc_put_request(req);
return -EIO;
}

--
2.25.1