mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eli Billauer <eli.billauer@gmail.com>
To: gregkh@linuxfoundation.org
Cc: arnd@arndb.de, linux-kernel@vger.kernel.org,
	Eli Billauer <eli.billauer@gmail.com>
Subject: [PATCH v2 2/8] char: xillybus: Safer access of unaligned pointers
Date: Tue, 17 Nov 2026 12:58:56 +0100	[thread overview]
Message-ID: <20261117115902.41359-3-eli.billauer@gmail.com> (raw)
In-Reply-To: <20261117115902.41359-1-eli.billauer@gmail.com>

Use get_unaligned_le16() rather than dereferencing unaligned pointers
directly for portability.

Fixes: a53d1202aef1 ("char: xillybus: Add driver for XillyUSB (Xillybus variant for USB)")
Assisted-by: Sashiko-0.2.5:gemini-3.1-pro-preview
Link: https://sashiko.dev/#/patchset/20260805093436.59740-1-eli.billauer%40gmail.com
Signed-off-by: Eli Billauer <eli.billauer@gmail.com>
---

Notes:
    Changes in v2:
    - Added Fixes: tag.

 drivers/char/xillybus/xillyusb.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/char/xillybus/xillyusb.c b/drivers/char/xillybus/xillyusb.c
index c4ddde221f0b..16d6101d9269 100644
--- a/drivers/char/xillybus/xillyusb.c
+++ b/drivers/char/xillybus/xillyusb.c
@@ -17,6 +17,7 @@
 #include <linux/device.h>
 #include <linux/module.h>
 #include <asm/byteorder.h>
+#include <linux/unaligned.h>
 #include <linux/io.h>
 #include <linux/interrupt.h>
 #include <linux/sched.h>
@@ -1957,8 +1958,8 @@ static int setup_channels(struct xillyusb_dev *xdev,
 	new_channels = chan;
 
 	for (i = 0; i < num_channels; i++, chan++) {
-		unsigned int in_desc = le16_to_cpu(*chandesc++);
-		unsigned int out_desc = le16_to_cpu(*chandesc++);
+		unsigned int in_desc = get_unaligned_le16(chandesc++);
+		unsigned int out_desc = get_unaligned_le16(chandesc++);
 
 		chan->xdev = xdev;
 		mutex_init(&chan->in_mutex);
@@ -2105,7 +2106,7 @@ static int xillyusb_discovery(struct usb_interface *interface)
 
 	/* Phase II: Set up the streams as defined in IDT */
 
-	num_channels = le16_to_cpu(*((__le16 *)(idt + 1)));
+	num_channels = get_unaligned_le16(idt + 1);
 	names_offset = 3 + num_channels * 4;
 	idt_len -= 4; /* Exclude CRC */
 
-- 
2.17.1


  parent reply	other threads:[~2026-11-17 11:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 11:58 [PATCH v2 0/8] char: xillybus: Fix issues reported by Sashiko Eli Billauer
2026-11-17 11:58 ` [PATCH v2 1/8] char: xillybus: Improve sanity check Eli Billauer
2026-11-17 11:58 ` Eli Billauer [this message]
2026-11-17 11:58 ` [PATCH v2 3/8] char: xillybus: Return error in fops read method handler Eli Billauer
2026-11-17 11:58 ` [PATCH v2 4/8] char: xillybus: Rely on FMODE flags in poll method Eli Billauer
2026-11-17 11:58 ` [PATCH v2 5/8] char: xillybus: Refactor flush function Eli Billauer
2026-11-17 11:59 ` [PATCH v2 6/8] char: xillybus: Correct handling of wait queue Eli Billauer
2026-11-17 11:59 ` [PATCH v2 7/8] char: xillybus: Avoid indefinite sleep of work item Eli Billauer
2026-11-17 11:59 ` [PATCH v2 8/8] char: xillybus: Cancel delayed work items before teardown Eli Billauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261117115902.41359-3-eli.billauer@gmail.com \
    --to=eli.billauer@gmail.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®