[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] target/ppc/kvm: Skip ".." directory in kvmppc_find_cpu_dt
From: |
David Gibson |
Subject: |
Re: [PATCH] target/ppc/kvm: Skip ".." directory in kvmppc_find_cpu_dt |
Date: |
Tue, 12 Jul 2022 13:46:08 +1000 |
On Mon, Jul 11, 2022 at 04:37:43PM -0300, 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>
> ---
> target/ppc/kvm.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
> index 6eed466f80..c8485a5cc0 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 upper directory */
> + if (strcmp(dirp->d_name, "..") == 0) {
It might not be causing problems now, but it would be technically more
correct to also skip ".", wouldn't it?
> + continue;
> + }
> +
> snprintf(buf, buf_len, "%s%s/clock-frequency", PROC_DEVTREE_CPU,
> dirp->d_name);
> f = fopen(buf, "r");
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
signature.asc
Description: PGP signature