From: Roland Dreier Date: Fri, 24 Feb 2012 01:22:12 +0000 (-0800) Subject: target: Fix 16-bit target ports for SET TARGET PORT GROUPS emulation X-Git-Tag: firefly_0821_release~7541^2~1495 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=91e4c264a6f7b2de2fa5d996db9297e99bfb1006;p=firefly-linux-kernel-4.4.55.git target: Fix 16-bit target ports for SET TARGET PORT GROUPS emulation commit 33395fb8a13731c7ef7b175dbf5a4d8a6738fe6c 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: Roland Dreier Signed-off-by: Nicholas Bellinger Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c index 86b36600acb4..c9674059213e 100644 --- a/drivers/target/target_core_alua.c +++ b/drivers/target/target_core_alua.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -238,8 +239,7 @@ int core_emulate_set_target_port_groups(struct se_cmd *cmd) * 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 @@ -280,8 +280,7 @@ int core_emulate_set_target_port_groups(struct se_cmd *cmd) * 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.