diff mbox series

[-next] lockdep: Use memset_startat() helper in reinit_class()

Message ID 20211213132618.105737-1-xiujianfeng@huawei.com (mailing list archive)
State Mainlined
Commit e204193b138af347fbbbe026e68cb3385112f387
Headers show
Series [-next] lockdep: Use memset_startat() helper in reinit_class() | expand

Commit Message

Xiu Jianfeng Dec. 13, 2021, 1:26 p.m. UTC
use memset_startat() helper to simplify the code, there is no functional
change in this patch.

Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
---
 kernel/locking/lockdep.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Peter Zijlstra Dec. 13, 2021, 2:32 p.m. UTC | #1
On Mon, Dec 13, 2021 at 09:26:18PM +0800, Xiu Jianfeng wrote:
> use memset_startat() helper to simplify the code, there is no functional
> change in this patch.
> 
> Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>

Thanks!
Waiman Long Dec. 13, 2021, 4:31 p.m. UTC | #2
On 12/13/21 08:26, Xiu Jianfeng wrote:
> use memset_startat() helper to simplify the code, there is no functional
> change in this patch.
>
> Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
> ---
>   kernel/locking/lockdep.c | 5 +----
>   1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> index 4a882f83aeb9..89b3df51fd98 100644
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -6011,13 +6011,10 @@ static void zap_class(struct pending_free *pf, struct lock_class *class)
>   
>   static void reinit_class(struct lock_class *class)
>   {
> -	void *const p = class;
> -	const unsigned int offset = offsetof(struct lock_class, key);
> -
>   	WARN_ON_ONCE(!class->lock_entry.next);
>   	WARN_ON_ONCE(!list_empty(&class->locks_after));
>   	WARN_ON_ONCE(!list_empty(&class->locks_before));
> -	memset(p + offset, 0, sizeof(*class) - offset);
> +	memset_startat(class, 0, key);
>   	WARN_ON_ONCE(!class->lock_entry.next);
>   	WARN_ON_ONCE(!list_empty(&class->locks_after));
>   	WARN_ON_ONCE(!list_empty(&class->locks_before));

LGTM

Acked-by: Waiman Long <longman@redhat.com>
Kees Cook Dec. 13, 2021, 8:39 p.m. UTC | #3
On Mon, Dec 13, 2021 at 09:26:18PM +0800, Xiu Jianfeng wrote:
> use memset_startat() helper to simplify the code, there is no functional
> change in this patch.
> 
> Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>

Reviewed-by: Kees Cook <keescook@chromium.org>
diff mbox series

Patch

diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 4a882f83aeb9..89b3df51fd98 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -6011,13 +6011,10 @@  static void zap_class(struct pending_free *pf, struct lock_class *class)
 
 static void reinit_class(struct lock_class *class)
 {
-	void *const p = class;
-	const unsigned int offset = offsetof(struct lock_class, key);
-
 	WARN_ON_ONCE(!class->lock_entry.next);
 	WARN_ON_ONCE(!list_empty(&class->locks_after));
 	WARN_ON_ONCE(!list_empty(&class->locks_before));
-	memset(p + offset, 0, sizeof(*class) - offset);
+	memset_startat(class, 0, key);
 	WARN_ON_ONCE(!class->lock_entry.next);
 	WARN_ON_ONCE(!list_empty(&class->locks_after));
 	WARN_ON_ONCE(!list_empty(&class->locks_before));