diff --git a/include/spdk/stdinc.h b/include/spdk/stdinc.h index 866632541..2490dd63d 100644 --- a/include/spdk/stdinc.h +++ b/include/spdk/stdinc.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: BSD-3-Clause * Copyright (C) 2017 Intel Corporation. * All rights reserved. + * Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ /** \file @@ -39,6 +40,7 @@ extern "C" { #include #include #include +#include #include #include #include diff --git a/module/bdev/uring/bdev_uring.c b/module/bdev/uring/bdev_uring.c index 3512e01b5..c000e7b75 100644 --- a/module/bdev/uring/bdev_uring.c +++ b/module/bdev/uring/bdev_uring.c @@ -307,11 +307,17 @@ bdev_uring_read_sysfs_attr(const char *devname, const char *attr, char *str, int { char *path = NULL; char *device = NULL; + char *name; FILE *file; int ret = 0; - device = basename(devname); + name = strdup(devname); + if (name == NULL) { + return -EINVAL; + } + device = basename(name); path = spdk_sprintf_alloc("/sys/block/%s/%s", device, attr); + free(name); if (!path) { return -EINVAL; }