mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: John Garry <john.g.garry@oracle.com>
To: Bart Van Assche <bvanassche@acm.org>,
	Juergen Gross <jgross@suse.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH] scsi: Let scsi_execute_cmd() mark args->sshdr as invalid
Date: Fri, 19 May 2023 18:12:01 +0100	[thread overview]
Message-ID: <611e1210-d89b-9046-ac3f-68a89af6159e@oracle.com> (raw)
In-Reply-To: <c9f0bc23-d5c1-23ba-2752-d89be9fef04a@acm.org>

On 19/05/2023 17:54, Bart Van Assche wrote:
> On 5/19/23 09:06, John Garry wrote:
>> Sure, what I describe is ideal, 

* not ideal

To be clear, I mean something like:

struct scsi_exec_args {
	unsigned char **sense;
}

scsi_execute_cmd()
{
	...
	*args->sense = kmemdup(scsi_cmd->sense_buffer);
	...
}

some_func()
{
	unsigned char *sense = NULL;
	struct  scsi_exec_args = {
		.sense = &sense,
	};

	ret = scsi_execute_cmd();
	if (ret < 0)
		return ret;
	kfree(sense);
}

But not perfect as we need a separate small buffer for sensehdr and we 
need to always kfree those buffers.

If only we could pass the actual scsi_cmnd sense buffer to the caller...

>but I still just dislike passing both 
>> sensebuf and hdr into scsi_execute_cmd(). The semantics of how 
>> scsi_execute_cmd() treats them is vague.
> 
> Is this something that can be addressed by improving the 
> scsi_execute_cmd() documentation?

Hmmm, I'm not sure documentation helps too much avoiding all programming 
errors and better make the code foolproof.

Anyway, if we fix up the callers of scsi_execute_cmd() to properly check 
for errors then if is not such a big deal.

Thanks,
John


  reply	other threads:[~2023-05-19 17:12 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-11 12:34 Juergen Gross
2023-05-11 12:49 ` Bart Van Assche
2023-05-11 12:54   ` Juergen Gross
2023-05-11 13:10 ` Martin Wilck
2023-05-11 13:17   ` Juergen Gross
2023-05-11 13:23     ` Martin Wilck
2023-05-11 13:32       ` Juergen Gross
2023-05-11 15:59         ` Martin Wilck
2023-05-11 16:00 ` Martin Wilck
2023-05-17  2:06 ` Martin K. Petersen
2023-05-17  4:54   ` Juergen Gross
2023-05-17 15:05     ` John Garry
2023-05-18  4:53       ` Juergen Gross
2023-05-18 10:57         ` John Garry
2023-05-18 19:54           ` Bart Van Assche
2023-05-19 16:06             ` John Garry
2023-05-19 16:54               ` Bart Van Assche
2023-05-19 17:12                 ` John Garry [this message]
2023-05-19 17:39                   ` Bart Van Assche
2023-05-22  9:55                     ` John Garry
2023-05-22 13:31                       ` Bart Van Assche
2023-05-22 15:54                         ` John Garry
2023-05-22 22:48                           ` michael.christie
2023-05-21  1:19           ` Martin K. Petersen
2023-05-21  5:23             ` Juergen Gross
2023-05-22 22:26               ` Martin K. Petersen
2023-05-23 15:04             ` Mike Christie
2023-05-21  0:46     ` Martin K. Petersen

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=611e1210-d89b-9046-ac3f-68a89af6159e@oracle.com \
    --to=john.g.garry@oracle.com \
    --cc=bvanassche@acm.org \
    --cc=jejb@linux.ibm.com \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=stable@vger.kernel.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

all inboxes | Powered by JetHome®