Skip to contentSkip to conversation

Fix auto resize code

PATCH In review Benjamin Marzinski 2 participants 4 messages Jan 17, 2024 Device mapper

lore
Share & tools
lore

Benjamin Marzinski

author maintainer
#0 lore raw

v2 cover Fix auto resize code

Fix two bugs in my auto-resize feature.

changes from v1 (based on suggestions from Martin Wilck):
0002: Explicitly set the default values of auto_resize

Benjamin Marzinski (2):
multipathd: fix null pointer dereference in uev_update_path
multipathd: fix auto-resize configuration

 libmultipath/config.c  | 1 +
 libmultipath/structs.h | 1 -
 multipathd/main.c      | 2 +-
 3 files changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.43.0
author maintainer
#1 lore raw

PATCH v2 1/2 multipathd: fix null pointer dereference in uev_update_path

The Auto-resize code added a check that deferences pp->mpp without checking that it's non-NULL. Fix it.

Fixes 981b83ad1 ("multipathd: Add auto_resize config option")
---
 multipathd/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
multipathd/main.c +1 -1
index 74f6cd92..fbc3f8da 100644
@@ -1630,7 +1630,7 @@ uev_update_path (struct uevent *uev, struct vectors * vecs)
 				}
 			}
 		}
-		if (auto_resize != AUTO_RESIZE_NEVER &&
+		if (auto_resize != AUTO_RESIZE_NEVER && mpp &&
 		    !mpp->wait_for_udev) {
 			struct pathgroup *pgp;
 			struct path *pp2;
Signature · 1 line
2.43.0
author maintainer
#2 lore raw

PATCH v2 2/2 multipathd: fix auto-resize configuration

In reply to Benjamin Marzinski

The code acted like AUTO_RESIZE_UNDEFINED didn't exist, but since conf->auto_resize was never set to AUTO_RESIZE_NEVER, the default was in fact AUTO_RESIZE_UNDEFINED, which ended up getting treated like AUTO_RESIZE_GROW_SHRINK. Remove AUTO_RESIZE_UNDEFINED and explicitly default auto_resize tp AUTO_RESIZE_NEVER.

Fixes 981b83ad1 ("multipathd: Add auto_resize config option")
---
 libmultipath/config.c  | 1 +
 libmultipath/structs.h | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)
libmultipath/config.c +1 -0
index b7dbc6f5..83fa7369 100644
@@ -927,6 +927,7 @@ int _init_config (const char *file, struct config *conf)
 	conf->retrigger_tries = DEFAULT_RETRIGGER_TRIES;
 	conf->retrigger_delay = DEFAULT_RETRIGGER_DELAY;
 	conf->uev_wait_timeout = DEFAULT_UEV_WAIT_TIMEOUT;
+	conf->auto_resize = DEFAULT_AUTO_RESIZE;
 	conf->remove_retries = 0;
 	conf->ghost_delay = DEFAULT_GHOST_DELAY;
 	conf->all_tg_pt = DEFAULT_ALL_TG_PT;
libmultipath/structs.h +0 -1
index a1aac1b4..734905e2 100644
@@ -180,7 +180,6 @@ enum queue_mode_states {
 };
 
 enum auto_resize_state {
-	AUTO_RESIZE_UNDEF = 0,
 	AUTO_RESIZE_NEVER,
 	AUTO_RESIZE_GROW_ONLY,
 	AUTO_RESIZE_GROW_SHRINK,
Signature · 1 line
2.43.0
Reviewed-by on the v2 series
#3 lore raw
In reply to Benjamin Marzinski
Quoted 5 lines · Benjamin Marzinski

Fix two bugs in my auto-resize feature.

changes from v1 (based on suggestions from Martin Wilck):
0002: Explicitly set the default values of auto_resize

Quoted 9 lines

Benjamin Marzinski (2):
  multipathd: fix null pointer dereference in uev_update_path
  multipathd: fix auto-resize configuration

 libmultipath/config.c  | 1 +
 libmultipath/structs.h | 1 -
 multipathd/main.c      | 2 +-

 3 files changed, 2 insertions(+), 2 deletions(-)

For the series: