Skip to content

Commit

Permalink
scsi: hpsa: Fix pointer dereferenced before checking
Browse files Browse the repository at this point in the history
The dev->raid_map is dereferencing before null checking, so move
 it after checking.

Signed-off-by: Haowen Bai <baihaowen@meizu.com>
  • Loading branch information
Lotte-Bai authored and intel-lab-lkp committed May 30, 2022
1 parent c4068bc commit 9a31054
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/scsi/hpsa.c
Expand Up @@ -5104,7 +5104,7 @@ static int hpsa_scsi_ioaccel_raid_map(struct ctlr_info *h,
{
struct scsi_cmnd *cmd = c->scsi_cmd;
struct hpsa_scsi_dev_t *dev = cmd->device->hostdata;
struct raid_map_data *map = &dev->raid_map;
struct raid_map_data *map;
struct raid_map_disk_data *dd = &map->data[0];
int is_write = 0;
u32 map_index;
Expand Down Expand Up @@ -5137,6 +5137,8 @@ static int hpsa_scsi_ioaccel_raid_map(struct ctlr_info *h,
if (!dev)
return -1;

map = &dev->raid_map;

if (dev->in_reset)
return -1;

Expand Down

0 comments on commit 9a31054

Please sign in to comment.