mtip32xx: fix potential crash on SEC_ERASE_UNIT
PATCH 1/3 mtip32xx: fix potential crash on SEC_ERASE_UNIT
The mtip driver lifted this code from elsewhere and then added a special handling check for SEC_ERASE_UNIT. If the caller tries to do a security erase but passes no output data for the command then outbuf is not allocated and the driver duly explodes.
Reported-by Dan Carpenter <[email protected]>
Signed-off-by Alan Cox <[email protected]>
Signed-off-by Selvan Mani <[email protected]>
Signed-off-by Asai Thambi S P <[email protected]>
--- drivers/block/mtip32xx/mtip32xx.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/block/mtip32xx/mtip32xx.c +2 -2
@@ -2218,8 +2218,8 @@ static int exec_drive_taskfile(struct driver_data *dd, fis.device);/* check for erase mode support during secure erase.*/ -if ((fis.command ==ATA_CMD_SEC_ERASE_UNIT ) - && (outbuf[0 ] &MTIP_SEC_ERASE_MODE )) { +if ((fis.command ==ATA_CMD_SEC_ERASE_UNIT ) && outbuf && + (outbuf[0 ] &MTIP_SEC_ERASE_MODE )) { erasemode =1 ; }
Signature · 1 line
1.7.1