在 2022/5/30 下午4:26, Haowen Bai 写道: > The dev->raid_map is dereferencing before null checking, so move > it after checking. > > Signed-off-by: Haowen Bai <baihaowen@xxxxxxxxx> > --- > drivers/scsi/hpsa.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c > index a47bcce3c9c7..fa785f60b1e6 100644 > --- a/drivers/scsi/hpsa.c > +++ b/drivers/scsi/hpsa.c > @@ -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; > @@ -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; > Sorry, plz ignore this patch. dev->raid_map is dereferenced, &dev->raid_map is just a pointer math for pointer address offset, so it would not cause a bug(dereferencing null pointer). -- Haowen Bai