You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
systemd/SOURCES/0390-sd-device-make-device_...

48 lines
1.8 KiB

From 3b4d91e7ab44738f3773a3bfd4a6c5fb9bbc7322 Mon Sep 17 00:00:00 2001
From: Yu Watanabe <watanabe.yu+github@gmail.com>
Date: Mon, 9 Jan 2023 14:00:09 +0900
Subject: [PATCH] sd-device: make device_set_syspath() clear sysname and sysnum
Otherwise, when a new syspath is assigned to the sd-device object,
sd_device_get_sysname() or _sysnum() will provide an outdated device
name or number.
(cherry picked from commit 9a26098e90116fdb5fcffa03485b375ee0c82b6a)
Related: RHEL-5988
---
src/libsystemd/sd-device/device-private.c | 4 ----
src/libsystemd/sd-device/sd-device.c | 4 ++++
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/libsystemd/sd-device/device-private.c b/src/libsystemd/sd-device/device-private.c
index bc7a838608..2c1d922ea3 100644
--- a/src/libsystemd/sd-device/device-private.c
+++ b/src/libsystemd/sd-device/device-private.c
@@ -646,10 +646,6 @@ int device_rename(sd_device *device, const char *name) {
if (r < 0)
return r;
- /* Here, only clear the sysname and sysnum. They will be set when requested. */
- device->sysnum = NULL;
- device->sysname = mfree(device->sysname);
-
r = sd_device_get_property_value(device, "INTERFACE", &interface);
if (r == -ENOENT)
return 0;
diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c
index f2e142457b..c822a0b2f0 100644
--- a/src/libsystemd/sd-device/sd-device.c
+++ b/src/libsystemd/sd-device/sd-device.c
@@ -250,6 +250,10 @@ int device_set_syspath(sd_device *device, const char *_syspath, bool verify) {
free_and_replace(device->syspath, syspath);
device->devpath = devpath;
+
+ /* Unset sysname and sysnum, they will be assigned when requested. */
+ device->sysnum = NULL;
+ device->sysname = mfree(device->sysname);
return 0;
}