Skip to content

Commit e01a00f

Browse files
Sergei Trofimovichmartinkpetersen
authored andcommitted
scsi: hpsa: Add an assert to prevent __packed reintroduction
Link: https://lore.kernel.org/r/[email protected] Fixes: f749d8b ("scsi: hpsa: Correct dev cmds outstanding for retried cmds") CC: [email protected] CC: [email protected] CC: [email protected] CC: Joe Szczypek <[email protected]> CC: Scott Benesh <[email protected]> CC: Scott Teel <[email protected]> CC: Tomas Henzl <[email protected]> CC: "Martin K. Petersen" <[email protected]> CC: Don Brace <[email protected]> Reported-by: John Paul Adrian Glaubitz <[email protected]> Suggested-by: Don Brace <[email protected]> Reviewed-by: Arnd Bergmann <[email protected]> Signed-off-by: Sergei Trofimovich <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 02ec144 commit e01a00f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/scsi/hpsa_cmd.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222

2323
#include <linux/compiler.h>
2424

25+
#include <linux/build_bug.h> /* static_assert */
26+
#include <linux/stddef.h> /* offsetof */
27+
2528
/* general boundary defintions */
2629
#define SENSEINFOBYTES 32 /* may vary between hbas */
2730
#define SG_ENTRIES_IN_CMD 32 /* Max SG entries excluding chain blocks */
@@ -454,6 +457,15 @@ struct CommandList {
454457
atomic_t refcount; /* Must be last to avoid memset in hpsa_cmd_init() */
455458
} __aligned(COMMANDLIST_ALIGNMENT);
456459

460+
/*
461+
* Make sure our embedded atomic variable is aligned. Otherwise we break atomic
462+
* operations on architectures that don't support unaligned atomics like IA64.
463+
*
464+
* The assert guards against reintroductin against unwanted __packed to
465+
* the struct CommandList.
466+
*/
467+
static_assert(offsetof(struct CommandList, refcount) % __alignof__(atomic_t) == 0);
468+
457469
/* Max S/G elements in I/O accelerator command */
458470
#define IOACCEL1_MAXSGENTRIES 24
459471
#define IOACCEL2_MAXSGENTRIES 28

0 commit comments

Comments
 (0)