Commit fbd49ca4 authored by Roland Dreier's avatar Roland Dreier Committed by Greg Kroah-Hartman

target: Fix 16-bit target ports for SET TARGET PORT GROUPS emulation

commit 33395fb8 upstream.

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: default avatarRoland Dreier <roland@purestorage.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b794073e
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <linux/export.h> #include <linux/export.h>
#include <scsi/scsi.h> #include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h> #include <scsi/scsi_cmnd.h>
#include <asm/unaligned.h>
#include <target/target_core_base.h> #include <target/target_core_base.h>
#include <target/target_core_device.h> #include <target/target_core_device.h>
...@@ -268,8 +269,7 @@ int target_emulate_set_target_port_groups(struct se_task *task) ...@@ -268,8 +269,7 @@ int target_emulate_set_target_port_groups(struct se_task *task)
* changed. * changed.
*/ */
if (primary) { if (primary) {
tg_pt_id = ((ptr[2] << 8) & 0xff); tg_pt_id = get_unaligned_be16(ptr + 2);
tg_pt_id |= (ptr[3] & 0xff);
/* /*
* Locate the matching target port group ID from * Locate the matching target port group ID from
* the global tg_pt_gp list * the global tg_pt_gp list
...@@ -313,8 +313,7 @@ int target_emulate_set_target_port_groups(struct se_task *task) ...@@ -313,8 +313,7 @@ int target_emulate_set_target_port_groups(struct se_task *task)
* the Target Port in question for the the incoming * the Target Port in question for the the incoming
* SET_TARGET_PORT_GROUPS op. * SET_TARGET_PORT_GROUPS op.
*/ */
rtpi = ((ptr[2] << 8) & 0xff); rtpi = get_unaligned_be16(ptr + 2);
rtpi |= (ptr[3] & 0xff);
/* /*
* Locate the matching relative target port identifer * Locate the matching relative target port identifer
* for the struct se_device storage object. * for the struct se_device storage object.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment