teamd: fix ctx->hwaddr value assignment
diff mbox series

Message ID 20200521114522.230775-1-liuhangbin@gmail.com
State New
Headers show
Series
  • teamd: fix ctx->hwaddr value assignment
Related show

Commit Message

Hangbin Liu May 21, 2020, 11:45 a.m. UTC
We should use memcpy to copy the data to ctx->hwaddr.
Use ctx->hwaddr = hwaddr will change the ctx->hwaddr to
a wrong address and cause the team hwaddr unable to be updated.

Reported-by: Li Liang <liali@redhat.com>
Suggested-by: Xin Long <lucien.xin@gmail.com>
Fixes: 9ca6bf9 ("teamd: update ctx->hwaddr after setting team dev to new hwaddr")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 teamd/teamd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jiri Pirko May 22, 2020, 3:02 p.m. UTC | #1
Thu, May 21, 2020 at 01:45:22PM CEST, liuhangbin@gmail.com wrote:
>We should use memcpy to copy the data to ctx->hwaddr.
>Use ctx->hwaddr = hwaddr will change the ctx->hwaddr to
>a wrong address and cause the team hwaddr unable to be updated.
>
>Reported-by: Li Liang <liali@redhat.com>
>Suggested-by: Xin Long <lucien.xin@gmail.com>
>Fixes: 9ca6bf9 ("teamd: update ctx->hwaddr after setting team dev to new hwaddr")
>Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>

applied, thanks!

Patch
diff mbox series

diff --git a/teamd/teamd.c b/teamd/teamd.c
index f955b19..9360cbf 100644
--- a/teamd/teamd.c
+++ b/teamd/teamd.c
@@ -896,7 +896,7 @@  static int teamd_hwaddr_check_change(struct teamd_context *ctx,
 		teamd_log_err("Failed to set team device hardware address.");
 		return err;
 	}
-	ctx->hwaddr = hwaddr;
+	memcpy(ctx->hwaddr, hwaddr, hwaddr_len);
 	ctx->hwaddr_len = hwaddr_len;
 	return 0;
 }