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

From: John Garry
Date: Mon May 22 2023 - 11:54:53 EST


On 22/05/2023 14:31, Bart Van Assche wrote:
On 5/22/23 02:55, John Garry wrote:
On 19/05/2023 18:39, Bart Van Assche wrote:
       *args->resid = scmd->resid_len;
-    if (args->sense)
-        memcpy(args->sense, scmd->sense_buffer, SCSI_SENSE_BUFFERSIZE);
+    if (args->sense) {
+        *args->sense = scmd->sense_buffer;
+        scmd->sense_buffer = NULL;

I think that you will agree that this is not a good pattern to follow. We cannot have SCSI core allocating the sense buffer but a driver freeing it.

Why not? Something similar can happen anywhere in the kernel anywhere reference counting is used.

Sure, but you are not using ref counting. If you could use ref counting then it would be better.

Thanks,
John