diff mbox series

libdaxctl: Add accurate check for daxctl_memory_op(MEM_GET_ZONE)

Message ID 20231009103521.1463-1-yangx.jy@fujitsu.com
State Accepted
Commit 91fba87dc397aa67e334d17d8f8d0032854c3b1d
Headers show
Series libdaxctl: Add accurate check for daxctl_memory_op(MEM_GET_ZONE) | expand

Commit Message

Xiao Yang Oct. 9, 2023, 10:35 a.m. UTC
The return number of daxctl_memory_op(MEM_GET_ZONE) indicates
how many memory blocks have the same memory zone. So It's wrong
to compare mem->zone and zone only when zero is returned.

Signed-off-by: Xiao Yang <yangx.jy@fujitsu.com>
---
 daxctl/lib/libdaxctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Dave Jiang Oct. 13, 2023, 10:27 p.m. UTC | #1
On 10/9/23 03:35, Xiao Yang wrote:
> The return number of daxctl_memory_op(MEM_GET_ZONE) indicates
> how many memory blocks have the same memory zone. So It's wrong
> to compare mem->zone and zone only when zero is returned.
> 
> Signed-off-by: Xiao Yang <yangx.jy@fujitsu.com>

You are correct. Thanks.

Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
>  daxctl/lib/libdaxctl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/daxctl/lib/libdaxctl.c b/daxctl/lib/libdaxctl.c
> index b27a8af..4f9aba0 100644
> --- a/daxctl/lib/libdaxctl.c
> +++ b/daxctl/lib/libdaxctl.c
> @@ -1616,7 +1616,7 @@ static int daxctl_memory_online_with_zone(struct daxctl_memory *mem,
>  	 */
>  	mem->zone = 0;
>  	rc = daxctl_memory_op(mem, MEM_GET_ZONE);
> -	if (rc)
> +	if (rc < 0)
>  		return rc;
>  	if (mem->zone != zone) {
>  		err(ctx,
diff mbox series

Patch

diff --git a/daxctl/lib/libdaxctl.c b/daxctl/lib/libdaxctl.c
index b27a8af..4f9aba0 100644
--- a/daxctl/lib/libdaxctl.c
+++ b/daxctl/lib/libdaxctl.c
@@ -1616,7 +1616,7 @@  static int daxctl_memory_online_with_zone(struct daxctl_memory *mem,
 	 */
 	mem->zone = 0;
 	rc = daxctl_memory_op(mem, MEM_GET_ZONE);
-	if (rc)
+	if (rc < 0)
 		return rc;
 	if (mem->zone != zone) {
 		err(ctx,