Skip to content

Commit

Permalink
cciss: add BUILD_BUG_ON() for catching bad CommandList_struct alignment
Browse files Browse the repository at this point in the history
The hardware requires 64-bit alignment of commands, so add a build bug
check for that. The recent commit 8a3173d
didn't change the size of the command, but other additions/changes may and
thus break badly at runtime.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
  • Loading branch information
Jens Axboe committed Mar 24, 2009
1 parent a7fcd37 commit 10cbda9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/block/cciss.c
Original file line number Diff line number Diff line change
Expand Up @@ -3898,6 +3898,13 @@ static struct pci_driver cciss_pci_driver = {
*/
static int __init cciss_init(void)
{
/*
* The hardware requires that commands are aligned on a 64-bit
* boundary. Given that we use pci_alloc_consistent() to allocate an
* array of them, the size must be a multiple of 8 bytes.
*/
BUILD_BUG_ON(sizeof(CommandList_struct) % 8);

printk(KERN_INFO DRIVER_NAME "\n");

/* Register for our PCI devices */
Expand Down

0 comments on commit 10cbda9

Please sign in to comment.