qemu-ppc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] target/ppc/kvm: Skip current and parent directories in kv


From: Daniel Henrique Barboza
Subject: Re: [PATCH v2] target/ppc/kvm: Skip current and parent directories in kvmppc_find_cpu_dt
Date: Thu, 14 Jul 2022 10:00:48 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0



On 7/12/22 18:08, Murilo Opsfelder Araujo wrote:
Some systems have /proc/device-tree/cpus/../clock-frequency. However,
this is not the expected path for a CPU device tree directory.

Signed-off-by: Murilo Opsfelder Araujo <muriloo@linux.ibm.com>
Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>
---

Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>


and queued.


Daniel

v2:
- Skip current and parent directories.

v1: 
20220711193743.51456-1-muriloo@linux.ibm.com/">https://lore.kernel.org/qemu-devel/20220711193743.51456-1-muriloo@linux.ibm.com/

  target/ppc/kvm.c | 6 ++++++
  1 file changed, 6 insertions(+)

diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
index 6eed466f80..466d0d2f4c 100644
--- a/target/ppc/kvm.c
+++ b/target/ppc/kvm.c
@@ -1877,6 +1877,12 @@ static int kvmppc_find_cpu_dt(char *buf, int buf_len)
      buf[0] = '\0';
      while ((dirp = readdir(dp)) != NULL) {
          FILE *f;
+
+        /* Don't accidentally read from the current and parent directories */
+        if (strcmp(dirp->d_name, ".") == 0 || strcmp(dirp->d_name, "..") == 0) 
{
+            continue;
+        }
+
          snprintf(buf, buf_len, "%s%s/clock-frequency", PROC_DEVTREE_CPU,
                   dirp->d_name);
          f = fopen(buf, "r");



reply via email to

[Prev in Thread] Current Thread [Next in Thread]