From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Alexandra Diupina <adiupina@astralinux.ru>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: Fam Zheng <fam@euphon.net>,
qemu-devel@nongnu.org, sdl.qemu@linuxtesting.org,
Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Subject: Re: [PATCH v2] esp: process the result of scsi_device_find()
Date: Fri, 29 Dec 2023 18:51:13 +0100 [thread overview]
Message-ID: <85be3ca7-4482-48cd-8676-8e2c192d4361@linaro.org> (raw)
In-Reply-To: <20231229152647.19699-1-adiupina@astralinux.ru>
Cc'ing Mark.
On 29/12/23 16:26, Alexandra Diupina wrote:
> Add a 'current_lun' check for a null value
> to avoid null pointer dereferencing and
> recover host if NULL return
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: 4eb8606560 (esp: store lun coming from the MESSAGE OUT phase)
> Signed-off-by: Alexandra Diupina <adiupina@astralinux.ru>
> ---
> v2: duplicate the scsi_device_find() logic from esp_select()
> hw/scsi/esp.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
> index 9b11d8c573..03fdd53de6 100644
> --- a/hw/scsi/esp.c
> +++ b/hw/scsi/esp.c
> @@ -292,6 +292,16 @@ static void do_command_phase(ESPState *s)
> esp_fifo_pop_buf(&s->cmdfifo, buf, cmdlen);
>
> current_lun = scsi_device_find(&s->bus, 0, s->current_dev->id, s->lun);
> +
> + if (!current_lun) {
> + /* No such drive */
> + s->rregs[ESP_RSTAT] = 0;
> + s->rregs[ESP_RINTR] = INTR_DC;
> + s->rregs[ESP_RSEQ] = SEQ_0;
> + esp_raise_irq(s);
> + return;
> + }
> +
> s->current_req = scsi_req_new(current_lun, 0, s->lun, buf, cmdlen, s);
> datalen = scsi_req_enqueue(s->current_req);
> s->ti_size = datalen;
next prev parent reply other threads:[~2023-12-29 17:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-18 15:02 [PATCH] esp: process the result of scsi_device_find() Alexandra Diupina
2023-12-26 12:08 ` Philippe Mathieu-Daudé
2023-12-27 20:02 ` Mark Cave-Ayland
2023-12-29 15:26 ` [PATCH v2] " Alexandra Diupina
2023-12-29 17:51 ` Philippe Mathieu-Daudé [this message]
2023-12-30 9:32 ` Paolo Bonzini
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=85be3ca7-4482-48cd-8676-8e2c192d4361@linaro.org \
--to=philmd@linaro.org \
--cc=adiupina@astralinux.ru \
--cc=fam@euphon.net \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=sdl.qemu@linuxtesting.org \
/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;
as well as URLs for NNTP newsgroup(s).