Re: [PATCH] scsi: Let scsi_execute_cmd() mark args->sshdr as invalid

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux