lkml.org 
[lkml]   [2023]   [May]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] scsi: Let scsi_execute_cmd() mark args->sshdr as invalid
From
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

\
 
 \ /
  Last update: 2023-05-19 19:12    [W:0.069 / U:0.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site