Skip to contentSkip to conversation

habanalabs: remove redundant memset

PATCH Applied Tom Rix 2 participants 2 messages Jan 7, 2023 – Jan 8, 2023

Subsystems (2)
lore
Share & tools
lore

Tom Rix

author
#0 lore raw

PATCH 1/1 habanalabs: remove redundant memset

From reviewing the code, the line
memset(kdata, 0, usize);
is not needed because kdata is either zeroed by
kdata = kzalloc(asize, GFP_KERNEL);
when allocated at runtime or by
char stack_kdata[128] = {0};
at compile time.

---
 drivers/accel/habanalabs/common/habanalabs_ioctl.c | 2 --
 1 file changed, 2 deletions(-)
drivers/accel/habanalabs/common/habanalabs_ioctl.c +0 -2
index 619d56c40b30..949d38527160 100644
@@ -1123,8 +1123,6 @@ static long _hl_ioctl(struct file *filep, unsigned int cmd, unsigned long arg,
 			retcode = -EFAULT;
 			goto out_err;
 		}
-	} else if (cmd & IOC_OUT) {
-		memset(kdata, 0, usize);
 	}
 
 	retcode = func(hpriv, kdata);
Signature · 1 line
2.27.0
maintainer Reviewed-by on v1 1/1 Applied
#1 lore raw
Quoted 28 lines · Tom Rix

From reviewing the code, the line
memset(kdata, 0, usize);
is not needed because kdata is either zeroed by
kdata = kzalloc(asize, GFP_KERNEL);
when allocated at runtime or by
char stack_kdata[128] = {0};
at compile time.

---
 drivers/accel/habanalabs/common/habanalabs_ioctl.c | 2 --
 1 file changed, 2 deletions(-)
drivers/accel/habanalabs/common/habanalabs_ioctl.c +0 -3
index 619d56c40b30..949d38527160 100644
@@ -1123,8 +1123,6 @@ static long _hl_ioctl(struct file *filep, unsigned int cmd, unsigned long arg,
                        retcode = -EFAULT;
                        goto out_err;
                }
-       } else if (cmd & IOC_OUT) {
-               memset(kdata, 0, usize);
        }
 
        retcode = func(hpriv, kdata);
--
Quoted 2 lines

2.27.0

Applied to -next.

Thanks,
Oded