[<prev] [next>] [day] [month] [year] [list]
Message-ID: <eMEUjRhhsu14WIezm_0PByc-vQUq0xntRpyizGCKFJoot3uhWvHqSXCCeXfwiY7jI6aEjUiiM-KXWLlyh1avJUZGqA6-pBZZDYtQ_VlYlk4=@proton.me>
Date: Tue, 17 Jun 2025 13:12:44 +0000
From: bard <bardr4@...ton.me>
To: "Jason@...c4.com" <Jason@...c4.com>, "tytso@....edu" <tytso@....edu>
Cc: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [PATCH] random: make error check in random_read_iter() more precise and readable
random: make error check in random_read_iter() more precise and readable
Currently, wait_for_random_bytes() only returns 0 on success or a negative error.
The check `if (ret != 0)` is functionally correct today, but fragile:
it would treat any unexpected positive value (should it ever be returned in the future)
as an error, which could cause incorrect behavior.
This patch replaces the check with `if (ret < 0)`, which makes the intent explicit:
only true error codes should trigger an early return. This improves code robustness
and makes the logic more readable to future maintainers by more clearly expressing
the expectations around `wait_for_random_bytes()`.
No functional change in current behavior.
Thanks a lot :)
Bar D.
Content of type "text/html" skipped
View attachment "0001-random-make-error-check-in-random_read_iter-more-pre.patch" of type "text/x-patch" (1398 bytes)
Powered by blists - more mailing lists