Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Jack Wallner <jackwallner@gmail.com>
To: Kees Cook <kees@kernel.org>
Cc: linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org,
	Ketan Mukadam <ketan.mukadam@broadcom.com>,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	"Martin K. Petersen" <mkp@kernel.org>,
	linux-scsi@vger.kernel.org
Subject: [PATCH 6/8] scsi: be2iscsi: Use ALIGN() on a DMA address
Date: Sun, 29 Nov 2026 00:56:08 -0800	[thread overview]
Message-ID: <20261129085612.22266-7-jackwallner@gmail.com> (raw)
In-Reply-To: <20261129085612.22266-1-jackwallner@gmail.com>

PTR_ALIGN() is meant for pointers. be_ctrl_init() passes it the DMA
address of the mailbox, a dma_addr_t. That compiles because PTR_ALIGN()
casts its argument to unsigned long and back.

A later patch in this series makes PTR_ALIGN() do pointer arithmetic on
its argument so that the compiler can keep track of the object size.
With that change this line gets -Wint-to-pointer-cast and
-Wpointer-to-int-cast warnings on 32-bit kernels with a 64-bit
dma_addr_t (x86 with PAE, for example).

Use ALIGN(), which works in the type of its argument. There is no change
on 64-bit kernels. On a 32-bit kernel with a 64-bit dma_addr_t the old
form would drop the upper 32 bits of the address. I have not seen that
happen and did not try to trigger it: this is a cleanup and a
prerequisite for the PTR_ALIGN() change, not a fix for a reported
problem.

Compile tested only, including i386 allmodconfig, which has a 64-bit
dma_addr_t.

The change and this changelog were written by an AI coding assistant
(Claude, run in Claude Code) at my direction. See the cover letter for
how it was used and tested.

Signed-off-by: Jack Wallner <jackwallner@gmail.com>
---
 drivers/scsi/be2iscsi/be_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index cadcaefaa..4e1387a39 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -561,7 +561,7 @@ static int be_ctrl_init(struct beiscsi_hba *phba, struct pci_dev *pdev)
 
 	mbox_mem_align->size = sizeof(struct be_mcc_mailbox);
 	mbox_mem_align->va = PTR_ALIGN(mbox_mem_alloc->va, 16);
-	mbox_mem_align->dma = PTR_ALIGN(mbox_mem_alloc->dma, 16);
+	mbox_mem_align->dma = ALIGN(mbox_mem_alloc->dma, 16);
 	memset(mbox_mem_align->va, 0, sizeof(struct be_mcc_mailbox));
 	mutex_init(&ctrl->mbox_lock);
 	spin_lock_init(&phba->ctrl.mcc_lock);
-- 
2.43.0


      reply	other threads:[~2026-11-29  8:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29  8:56 [PATCH 0/8] Preserve object size through PTR_ALIGN() Jack Wallner
2026-11-29  8:56 ` Jack Wallner [this message]

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=20261129085612.22266-7-jackwallner@gmail.com \
    --to=jackwallner@gmail.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=kees@kernel.org \
    --cc=ketan.mukadam@broadcom.com \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mkp@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