From 15474d8bd5405bc9e55dd084710929e06cd4d8f4 Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Mon, 14 Nov 2022 18:11:39 +0800 Subject: [PATCH] mount: fix mount failure with old kernels If the 'cmi->cmi_opts' has only one option and there is no any comma in it, when removing the 'mon_addr' it will fail. And will pass the 'mon_addr' option to the old kernels. Fixes: https://tracker.ceph.com/issues/58018 Signed-off-by: Xiubo Li (cherry picked from commit 3180332ec48596794e2ff4fff305119c4ec2caf7) --- src/mount/mount.ceph.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mount/mount.ceph.c b/src/mount/mount.ceph.c index 032c22e6c23f0..ff1b12c474e57 100644 --- a/src/mount/mount.ceph.c +++ b/src/mount/mount.ceph.c @@ -164,7 +164,9 @@ static int remove_opt(struct ceph_mount_info *cmi, const char *key, char **value memmove(key_start, value_end, len2); } else { /* last kv pair - swallow the comma */ - --key_start; + if (*(key_start - 1) == ',') { + --key_start; + } *key_start = '\0'; } -- 2.39.5