Skip to content

Commit

Permalink
target: Fix 16-bit target ports for SET TARGET PORT GROUPS emulation
Browse files Browse the repository at this point in the history
The old code did (MSB << 8) & 0xff, which always evaluates to 0.  Just use
get_unaligned_be16() so we don't have to worry about whether our open-coded
version is correct or not.

Signed-off-by: Roland Dreier <roland@purestorage.com>
Cc: stable@vger.kernel.org
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
  • Loading branch information
Roland Dreier authored and Nicholas Bellinger committed Feb 25, 2012
1 parent 355b769 commit 33395fb
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions drivers/target/target_core_alua.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <linux/export.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
#include <asm/unaligned.h>

#include <target/target_core_base.h>
#include <target/target_core_backend.h>
Expand Down Expand Up @@ -267,8 +268,7 @@ int target_emulate_set_target_port_groups(struct se_task *task)
* changed.
*/
if (primary) {
tg_pt_id = ((ptr[2] << 8) & 0xff);
tg_pt_id |= (ptr[3] & 0xff);
tg_pt_id = get_unaligned_be16(ptr + 2);
/*
* Locate the matching target port group ID from
* the global tg_pt_gp list
Expand Down Expand Up @@ -312,8 +312,7 @@ int target_emulate_set_target_port_groups(struct se_task *task)
* the Target Port in question for the the incoming
* SET_TARGET_PORT_GROUPS op.
*/
rtpi = ((ptr[2] << 8) & 0xff);
rtpi |= (ptr[3] & 0xff);
rtpi = get_unaligned_be16(ptr + 2);
/*
* Locate the matching relative target port identifer
* for the struct se_device storage object.
Expand Down

0 comments on commit 33395fb

Please sign in to comment.