|SUCCESS| examples: Fix vm_power_manager scratch area to /run/dpdk/powermanager
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Thu May 28 23:32:51 CEST 2026
Test-Label: ai-code-review
Test-Status: SUCCESS
https://dpdk.org/patch/164542
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-05-28
Review of vm_power_manager scratch area patch
git sha: 20260528190449.66254-1-giveback4fun at gmail.com
Author: Sudheendra Sampath <giveback4fun at gmail.com>
Subject: [PATCH] examples: Fix vm_power_manager scratch area to
/run/dpdk/powermanager
This patch modifies the vm_power_manager example to create its socket
directory under /run/dpdk/powermonitor/ instead of /tmp/powermonitor/.
It adds logic to create the parent /run/dpdk directory if needed and
validates that it is actually a directory.
> diff --git a/examples/vm_power_manager/channel_manager.c b/examples/vm_power_manager/channel_manager.c
> index b69449c61d..60d767ea98 100644
> --- a/examples/vm_power_manager/channel_manager.c
> +++ b/examples/vm_power_manager/channel_manager.c
> @@ -420,8 +420,33 @@ add_all_channels(const char *vm_name)
> if (d == NULL) {
> RTE_LOG(ERR, CHANNEL_MANAGER, "Error opening directory '%s': %s\n",
> CHANNEL_MGR_SOCKET_PATH, strerror(errno));
> - return -1;
> +
> + const char *run_dpdk = "/run/dpdk";
> + struct stat path_stat;
> + int ret;
According to DPDK coding style section 3.1, declarations should be at
the start of the function or block. These declarations appear after the
error log statement and initial check.
> +
> + if (stat(run_dpdk, &path_stat) != 0) {
The coding style guide section 4.3.3 states that comparisons to 0 should
be explicit. However, is there a potential race condition here between
the stat() check and the mkdir() call? Another process could create the
directory in between these two operations.
> + ret = mkdir(run_dpdk, 0700);
> + if (ret < 0 && errno != EEXIST) {
> + RTE_LOG(ERR, CHANNEL_MANAGER, "Error creating '%s': %s",
> + run_dpdk, strerror(errno));
> + return -1;
> + }
> + }
> +
> + /* Make sure /run/dpdk is a directory */
> + if (!S_ISDIR(path_stat.st_mode)) {
> + return -1;
> + }
Does this code use uninitialized data? If stat() fails above, path_stat
is never populated, yet this code unconditionally checks
path_stat.st_mode. Can this access undefined memory when stat() returned
nonzero?
Also, can this code fail silently? When /run/dpdk exists but is not a
directory, the function returns -1 without logging an error message.
> +
> + ret = mkdir(CHANNEL_MGR_SOCKET_PATH, 0700);
> + if (ret < 0 && errno != EEXIST) {
> + RTE_LOG(ERR, CHANNEL_MANAGER, "Error creating '%s': %s",
> + CHANNEL_MGR_SOCKET_PATH, strerror(errno));
> + return -1;
> + }
> }
Does this code have a logic flow issue? When the opendir() succeeds, d
is non-NULL and this entire block is skipped. But when it fails and this
code creates the directories, doesn't d remain NULL? Won't the readdir(d)
call below then pass NULL to readdir()?
> +
> while ((dir = readdir(d)) != NULL) {
> if (!strncmp(dir->d_name, ".", 1) ||
> !strncmp(dir->d_name, "..", 2))
[ ... ]
More information about the test-report
mailing list