Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: stm32/crc32 - fix parsing list of devices

smatch warnings:
drivers/crypto/stm32/stm32-crc32.c:108 stm32_crc_get_next_crc() warn:
can 'crc' even be NULL?

Use list_first_entry_or_null instead of list_first_entry to retrieve
the first device registered.
The function list_first_entry always return a non NULL pointer even if
the list is empty. Hence checking if the pointer returned is NULL does
not tell if the list is empty or not.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/r/202311281111.ou2oUL2i-lkp@intel.com/
Reported-by: Dan Carpenter <error27@gmail.com>
Closes: https://lore.kernel.org/r/202311281111.ou2oUL2i-lkp@intel.com/
Signed-off-by: Thomas Bourgoin <thomas.bourgoin@foss.st.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Thomas Bourgoin and committed by
Herbert Xu
0eaef675 fcf60f4b

+1 -1
+1 -1
drivers/crypto/stm32/stm32-crc32.c
··· 104 104 struct stm32_crc *crc; 105 105 106 106 spin_lock_bh(&crc_list.lock); 107 - crc = list_first_entry(&crc_list.dev_list, struct stm32_crc, list); 107 + crc = list_first_entry_or_null(&crc_list.dev_list, struct stm32_crc, list); 108 108 if (crc) 109 109 list_move_tail(&crc->list, &crc_list.dev_list); 110 110 spin_unlock_bh(&crc_list.lock);