[PATCH v2] nvmet: reject invalid write-protect feature values

Hannes Reinecke hare at suse.de
Mon Nov 9 23:17:51 PST 2026


On 11/9/26 3:24 PM, Sreeraj S Kurup wrote:
> The Set Features handler for namespace write protection currently
> accepts unsupported values. The default case in the write-protect
> switch leaves the status unchanged, causing the command to return
> success even though no valid setting was applied.
> 
> Return NVME_SC_INVALID_FIELD | NVME_STATUS_DNR for unsupported
> values. This also prevents issuing a namespace-change notification
> for an invalid request.
> 
> Fixes: 3a1f7c79ae6d ("nvmet: make nvmet_find_namespace() req based")
> Signed-off-by: Sreeraj S Kurup <sreekuttan2156239 at gmail.com>
> ---
> v2:
>   - Add Fixes trailer
> 
>   drivers/nvme/target/admin-cmd.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
> index f12d83098644..ee8be237485e 100644
> --- a/drivers/nvme/target/admin-cmd.c
> +++ b/drivers/nvme/target/admin-cmd.c
> @@ -1223,6 +1223,7 @@ static u16 nvmet_set_feat_write_protect(struct nvmet_req *req)
>   		status = 0;
>   		break;
>   	default:
> +		status = NVME_SC_INVALID_FIELD | NVME_STATUS_DNR;
>   		break;
>   	}
>   

Please send new versions as individual patchsets, not as replies to the
original patch.

Reviewed-by: Hannes Reinecke <hare at kernel.org>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                  Kernel Storage Architect
hare at suse.de                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich



More information about the Linux-nvme mailing list