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

crypto: cavium/nitrox - Fix 'nitrox_get_first_device()' when ndevlist is fully iterated

When a list is completely iterated with 'list_for_each_entry(x, ...)', x is
not NULL at the end.

While at it, remove a useless initialization of the ndev variable. It
is overridden by 'list_for_each_entry'.

Fixes: f2663872f073 ("crypto: cavium - Register the CNN55XX supported crypto algorithms.")
Cc: <stable@vger.kernel.org>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Christophe JAILLET and committed by
Herbert Xu
320bdbd8 281c3778

+2 -2
+2 -2
drivers/crypto/cavium/nitrox/nitrox_main.c
··· 278 278 279 279 struct nitrox_device *nitrox_get_first_device(void) 280 280 { 281 - struct nitrox_device *ndev = NULL; 281 + struct nitrox_device *ndev; 282 282 283 283 mutex_lock(&devlist_lock); 284 284 list_for_each_entry(ndev, &ndevlist, list) { ··· 286 286 break; 287 287 } 288 288 mutex_unlock(&devlist_lock); 289 - if (!ndev) 289 + if (&ndev->list == &ndevlist) 290 290 return NULL; 291 291 292 292 refcount_inc(&ndev->refcnt);