Commit 59e4f541baf728dbb426949bfa9f6862387ffd0e

Authored by Roland Dreier
Committed by Nicholas Bellinger
1 parent f2d5d9b90b

target: Return error to initiator if SET TARGET PORT GROUPS emulation fails

The error paths in target_emulate_set_target_port_groups() are all
essentially "rc = -EINVAL; goto out;" but the code at "out:" ignores
rc and always returns success.  This means that even if eg explicit
ALUA is turned off, the initiator will always see a good SCSI status
for SET TARGET PORT GROUPS.

Fix this by returning rc as is intended.  It appears this bug was
added by the following patch:

commit 05d1c7c0d0db4cc25548d9aadebb416888a82327
Author: Andy Grover <agrover@redhat.com>
Date:   Wed Jul 20 19:13:28 2011 +0000

    target: Make all control CDBs scatter-gather

Signed-off-by: Roland Dreier <roland@purestorage.com>
Cc: Andy Grover <agrover@redhat.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>

Showing 1 changed file with 3 additions and 2 deletions Side-by-side Diff

drivers/target/target_core_alua.c
... ... @@ -374,8 +374,9 @@
374 374  
375 375 out:
376 376 transport_kunmap_data_sg(cmd);
377   - target_complete_cmd(cmd, GOOD);
378   - return 0;
  377 + if (!rc)
  378 + target_complete_cmd(cmd, GOOD);
  379 + return rc;
379 380 }
380 381  
381 382 static inline int core_alua_state_nonoptimized(