From: baihaowen <baihaowen@meizu.com>
To: Don Brace <don.brace@microchip.com>,
"James E.J. Bottomley" <jejb@linux.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: <storagedev@microchip.com>, <linux-scsi@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] scsi: hpsa: Fix pointer dereferenced before checking
Date: Tue, 31 May 2022 09:40:20 +0800 [thread overview]
Message-ID: <0578e737-86de-610b-038f-4bdada7f962e@meizu.com> (raw)
In-Reply-To: <1653899188-26544-1-git-send-email-baihaowen@meizu.com>
在 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@meizu.com>
> ---
> 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
prev parent reply other threads:[~2022-05-31 1:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-30 8:26 Haowen Bai
2022-05-30 20:08 ` kernel test robot
2022-05-31 1:40 ` baihaowen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0578e737-86de-610b-038f-4bdada7f962e@meizu.com \
--to=baihaowen@meizu.com \
--cc=don.brace@microchip.com \
--cc=jejb@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=storagedev@microchip.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®