Re: [PATCH] libnvdimm: Handle negative return from nvdimm_clear_poison() in nsio_rw_bytes()
From: Alison Schofield
Date: Fri Oct 09 2026 - 21:56:57 EST
On Fri, Oct 02, 2026 at 07:56:41PM +0300, Serhat Kumral wrote:
> When nvdimm_clear_poison() fails, it returns a negative error code.
> However, 'cleared' is a signed long while 'size' is size_t.
> The comparison 'cleared < size' promotes 'cleared' to an unsigned long.
> So the error condition can be bypassed and the function can
> incorrectly return success if the subsequent flush succeeds.
>
> Explicitly check for negative error codes before comparing with 'size'.
The fix looks good to me. Thanks for addressing this.
Reviewed-by: Alison Schofield <alison.schofield@xxxxxxxxx>