Skip to contentSkip to conversation

crypto: chelsio - Move DMA un/mapping to chcr from lld cxgb4 driver

bug report Dan Carpenter 1 participant 1 message Nov 8, 2017 Crypto API

lore
Share & tools
lore
#0 lore raw

Hello Harsh Jain,

This is a semi-automatic email about new static checker warnings.

The patch 2f47d5804311: "crypto: chelsio - Move DMA un/mapping to chcr from lld cxgb4 driver" from Oct 8, 2017, leads to the following Smatch complaint:

drivers/crypto/chelsio/chcr_algo.c:562 ulptx_walk_add_sg()
error: we previously assumed 'sg' could be null (see line 551)

drivers/crypto/chelsio/chcr_algo.c
550

   551		while (sg && skip) {
                       ^^

The patch adds a new check for NULL

552 if (sg_dma_len(sg) <= skip) {
553 skip -= sg_dma_len(sg);
554 skip_len = 0;
555 sg = sg_next(sg);
556 } else {
557 skip_len = skip;
558 skip = 0;
559 }
560 }
561 if (walk->nents == 0) {

   562			small = min_t(unsigned int, sg_dma_len(sg) - skip_len, len);
                                                               ^^

This dereference (inside the macro) isn't checked.

   563			sgmin = min_t(unsigned int, small, CHCR_SRC_SG_SIZE);
   564			walk->sgl->len0 = cpu_to_be32(sgmin);

regards,
dan carpenter