Skip to content

Commit 78bf473

Browse files
David Kozubaxboe
authored andcommitted
block: sed-opal: fix IOC_OPAL_ENABLE_DISABLE_MBR
The implementation of IOC_OPAL_ENABLE_DISABLE_MBR handled the value opal_mbr_data.enable_disable incorrectly: enable_disable is expected to be one of OPAL_MBR_ENABLE(0) or OPAL_MBR_DISABLE(1). enable_disable was passed directly to set_mbr_done and set_mbr_enable_disable where is was interpreted as either OPAL_TRUE(1) or OPAL_FALSE(0). The end result was that calling IOC_OPAL_ENABLE_DISABLE_MBR with OPAL_MBR_ENABLE actually disabled the shadow MBR and vice versa. This patch adds correct conversion from OPAL_MBR_DISABLE/ENABLE to OPAL_FALSE/TRUE. The change affects existing programs using IOC_OPAL_ENABLE_DISABLE_MBR but this is typically used only once when setting up an Opal drive. Acked-by: Jon Derrick <jonathan.derrick@intel.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Scott Bauer <sbauer@plzdonthack.me> Signed-off-by: David Kozub <zub@linux.fjfi.cvut.cz> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 72deb45 commit 78bf473

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎block/sed-opal.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,13 +2095,16 @@ static int opal_erase_locking_range(struct opal_dev *dev,
20952095
static int opal_enable_disable_shadow_mbr(struct opal_dev *dev,
20962096
struct opal_mbr_data *opal_mbr)
20972097
{
2098+
u8 enable_disable = opal_mbr->enable_disable == OPAL_MBR_ENABLE ?
2099+
OPAL_TRUE : OPAL_FALSE;
2100+
20982101
const struct opal_step mbr_steps[] = {
20992102
{ opal_discovery0, },
21002103
{ start_admin1LSP_opal_session, &opal_mbr->key },
2101-
{ set_mbr_done, &opal_mbr->enable_disable },
2104+
{ set_mbr_done, &enable_disable },
21022105
{ end_opal_session, },
21032106
{ start_admin1LSP_opal_session, &opal_mbr->key },
2104-
{ set_mbr_enable_disable, &opal_mbr->enable_disable },
2107+
{ set_mbr_enable_disable, &enable_disable },
21052108
{ end_opal_session, },
21062109
{ NULL, }
21072110
};
@@ -2221,7 +2224,7 @@ static int __opal_lock_unlock(struct opal_dev *dev,
22212224

22222225
static int __opal_set_mbr_done(struct opal_dev *dev, struct opal_key *key)
22232226
{
2224-
u8 mbr_done_tf = 1;
2227+
u8 mbr_done_tf = OPAL_TRUE;
22252228
const struct opal_step mbrdone_step [] = {
22262229
{ opal_discovery0, },
22272230
{ start_admin1LSP_opal_session, key },

0 commit comments

Comments
 (0)