From 0a2331538fe25aae3e2d73c1f928c874a825e199 Mon Sep 17 00:00:00 2001 From: Fahim Hassan Date: Thu, 25 Jun 2026 09:48:40 -0500 Subject: [PATCH] nvme: fix uninitialized variable in get_feature_id_changed() The get_feature_id_changed() function retrieves and compares NVMe feature values. The local @result variable was left uninitialized before being passed to get_feature_id(). If get_feature_id() fails early, @result may be used without ever being assigned a valid value, leading to undefined behavior. Initialize @result to -EINVAL to indicate no feature value has been retrieved and prevent undefined behavior. Signed-off-by: Fahim Hassan --- nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvme.c b/nvme.c index 80b7a4a3d1..0ea351dc0f 100644 --- a/nvme.c +++ b/nvme.c @@ -4914,7 +4914,7 @@ static int get_feature_id_changed(struct libnvme_transport_handle *hdl, struct f __cleanup_libnvme_free void *buf_def = NULL; __cleanup_libnvme_free void *buf = NULL; __u64 result_def = 0; - __u64 result = 0; + __u64 result = -EINVAL; int err_def = 0; int err;