[PATCH v2] drivers/net/slip: prevent data alignment fault

William Tambe <[email protected]>
Newsgroups gmane.linux.ppp
Message-ID <CAF8i9mP0q9cKG+GigeQUd_YTZaOG6oTNzho+xrv8Bi3oPtJ2yA@mail.gmail.com>
From d30bc4e92236e72bb0a9a743f3ad605ea1c1152e Mon Sep 17 00:00:00 2001
From: William Tambe <[email protected]>
Date: Mon, 2 Oct 2023 10:16:54 -0500
Subject: [PATCH v2] drivers/net/slip: prevent data alignment fault

Prevent data alignment fault on architectures which cannot
do unaligned memory access.
---
 drivers/net/slip/slhc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
index ba93bab948e0..f198be2c7205 100644
--- a/drivers/net/slip/slhc.c
+++ b/drivers/net/slip/slhc.c
@@ -459,7 +459,7 @@ slhc_compress(struct slcompress *comp, unsigned
char *icp, int isize,
         *cpp = ocp;
         *cp++ = changes;
     }
-    *(__sum16 *)cp = csum;
+    put_unaligned(csum, (__sum16 *)cp);
     cp += 2;
 /* deltaS is now the size of the change section of the compressed header */
     memcpy(cp,new_seq,deltaS);    /* Write list of deltas */
@@ -534,7 +534,7 @@ slhc_uncompress(struct slcompress *comp, unsigned
char *icp, int isize)
     thp = &cs->cs_tcp;
     ip = &cs->cs_ip;

-    thp->check = *(__sum16 *)cp;
+    thp->check = get_unaligned((__sum16 *)cp);
     cp += 2;

     thp->psh = (changes & TCP_PUSH_BIT) ? 1 : 0;
-- 
2.34.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.