[PATCH] firmware_loader: Fix a NULL vs IS_ERR() check

Dan Carpenter posted 1 patch 2 years, 8 months ago
drivers/base/firmware_loader/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] firmware_loader: Fix a NULL vs IS_ERR() check
Posted by Dan Carpenter 2 years, 8 months ago
The crypto_alloc_shash() function doesn't return NULL, it returns
error pointers.  Update the check accordingly.

Fixes: 02fe26f25325 ("firmware_loader: Add debug message with checksum for FW file")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/base/firmware_loader/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c
index 9d79d5ad9102..b58c42f1b1ce 100644
--- a/drivers/base/firmware_loader/main.c
+++ b/drivers/base/firmware_loader/main.c
@@ -812,7 +812,7 @@ static void fw_log_firmware_info(const struct firmware *fw, const char *name, st
 	char *outbuf;
 
 	alg = crypto_alloc_shash("sha256", 0, 0);
-	if (!alg)
+	if (IS_ERR(alg))
 		return;
 
 	sha256buf = kmalloc(SHA256_DIGEST_SIZE, GFP_KERNEL);
-- 
2.39.2
Re: [PATCH] firmware_loader: Fix a NULL vs IS_ERR() check
Posted by Luis Chamberlain 2 years, 8 months ago
On Tue, May 16, 2023 at 11:12:51AM +0300, Dan Carpenter wrote:
> The crypto_alloc_shash() function doesn't return NULL, it returns
> error pointers.  Update the check accordingly.
> 
> Fixes: 02fe26f25325 ("firmware_loader: Add debug message with checksum for FW file")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Acked-by: Luis Chamberlain <mcgrof@kernel.org>

  Luis
Re: [PATCH] firmware_loader: Fix a NULL vs IS_ERR() check
Posted by Cezary Rojewski 2 years, 8 months ago
On 2023-05-16 10:12 AM, Dan Carpenter wrote:
> The crypto_alloc_shash() function doesn't return NULL, it returns
> error pointers.  Update the check accordingly.
> 
> Fixes: 02fe26f25325 ("firmware_loader: Add debug message with checksum for FW file")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>   drivers/base/firmware_loader/main.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c
> index 9d79d5ad9102..b58c42f1b1ce 100644
> --- a/drivers/base/firmware_loader/main.c
> +++ b/drivers/base/firmware_loader/main.c
> @@ -812,7 +812,7 @@ static void fw_log_firmware_info(const struct firmware *fw, const char *name, st
>   	char *outbuf;
>   
>   	alg = crypto_alloc_shash("sha256", 0, 0);
> -	if (!alg)
> +	if (IS_ERR(alg))
>   		return;
>   
>   	sha256buf = kmalloc(SHA256_DIGEST_SIZE, GFP_KERNEL);

Thank you for the fix.

Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>