mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Shigeru Yoshida <syoshida@redhat.com>,
	jejb@linux.ibm.com, martin.petersen@oracle.com
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scsi: sr: Fix a potential uninit-value in sr_get_events()
Date: Wed, 31 May 2023 15:44:17 -0700	[thread overview]
Message-ID: <c459dd2c-a281-7fc4-90cf-36a71e9548bc@acm.org> (raw)
In-Reply-To: <20230531164346.118438-1-syoshida@redhat.com>

On 5/31/23 09:43, Shigeru Yoshida wrote:
> diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
> index 12869e6d4ebd..86b43c069a44 100644
> --- a/drivers/scsi/sr.c
> +++ b/drivers/scsi/sr.c
> @@ -177,10 +177,13 @@ static unsigned int sr_get_events(struct scsi_device *sdev)
>   
>   	result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, buf, sizeof(buf),
>   				  SR_TIMEOUT, MAX_RETRIES, &exec_args);
> +	if (result)
> +		return 0;
> +
>   	if (scsi_sense_valid(&sshdr) && sshdr.sense_key == UNIT_ATTENTION)
>   		return DISK_EVENT_MEDIA_CHANGE;
>   
> -	if (result || be16_to_cpu(eh->data_len) < sizeof(*med))
> +	if (be16_to_cpu(eh->data_len) < sizeof(*med))
>   		return 0;

I think this change is wrong because it introduces an unintended behavior
change. A better solution is probably to zero-initialize sshdr before
scsi_execute_cmd() is called.

Thanks,

Bart.


  reply	other threads:[~2023-05-31 22:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-31 16:43 Shigeru Yoshida
2023-05-31 22:44 ` Bart Van Assche [this message]
2023-10-30  8:13   ` Shigeru Yoshida
2023-10-30 15:02     ` michael.christie

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=c459dd2c-a281-7fc4-90cf-36a71e9548bc@acm.org \
    --to=bvanassche@acm.org \
    --cc=jejb@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=syoshida@redhat.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

Powered by JetHome