sd-device: check fd validity before using in sendmsg in test

CID#1663676

Follow-up for 7003a9bf09
This commit is contained in:
Luca Boccassi
2026-07-08 13:36:32 +01:00
parent 6248f1b774
commit 7967b6b6d5
@@ -8,6 +8,7 @@
#include "device-monitor-private.h"
#include "device-private.h"
#include "device-util.h"
#include "fd-util.h"
#include "io-util.h"
#include "iovec-util.h"
#include "mountpoint-util.h"
@@ -444,7 +445,9 @@ TEST(sd_device_monitor_receive_bad_properties_off) {
.msg_name = &sa,
.msg_namelen = sizeof(struct sockaddr_nl),
};
ASSERT_OK_ERRNO(sendmsg(sd_device_monitor_get_fd(monitor_server), &smsg, 0));
int fd = ASSERT_FD(sd_device_monitor_get_fd(monitor_server));
ASSERT_OK_ERRNO(sendmsg(fd, &smsg, 0));
_cleanup_(sd_device_unrefp) sd_device *dev = NULL;
ASSERT_ERROR(sd_device_monitor_receive(monitor_client, &dev), EAGAIN);