Skip to contentSkip to conversation

crypto: brcm - Add Broadcom SPU driver

bug report Dan Carpenter 1 participant 1 message Feb 14, 2017 Crypto API

lore
Share & tools
lore
#0 lore raw

Hello Rob Rice,

The patch 9d12ba86f818: "crypto: brcm - Add Broadcom SPU driver" from Feb 3, 2017, leads to the following static checker warning:

	drivers/crypto/bcm/cipher.c:2340 ahash_finup()
	warn: 'tmpbuf' was already freed.

drivers/crypto/bcm/cipher.c
2316 /* Copy data from req scatterlist to tmp buffer */
2317 gfp = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG |
2318 CRYPTO_TFM_REQ_MAY_SLEEP)) ? GFP_KERNEL : GFP_ATOMIC;
2319 tmpbuf = kmalloc(req->nbytes, gfp);
2320 if (!tmpbuf) {
2321 ret = -ENOMEM;
2322 goto ahash_finup_exit;
2323 }
2324
2325 if (sg_copy_to_buffer(req->src, nents, tmpbuf, req->nbytes) !=
2326 req->nbytes) {
2327 ret = -EINVAL;
2328 goto ahash_finup_free;
2329 }
2330
2331 /* Call synchronous update */
2332 ret = crypto_shash_finup(ctx->shash, tmpbuf, req->nbytes,
2333 req->result);

  2334                  kfree(tmpbuf);
                        ^^^^^^^^^^^^^
  2335          } else {
  2336                  /* Otherwise call the internal function which uses SPU hw */
  2337                  return __ahash_finup(req);
  2338          }
  2339  ahash_finup_free:
  2340          kfree(tmpbuf);
                ^^^^^^^^^^^^^

I'm only working a 30 minutes per day to keep a hand in. I'm not sending patches this month.

  2341  
  2342  ahash_finup_exit:
  2343          /* Done with hash, can deallocate it now */
  2344          crypto_free_shash(ctx->shash->tfm);
  2345          kfree(ctx->shash);
  2346          return ret;
  2347  }

regards,
dan carpenter