[cryptodev:master 147/154] drivers/crypto/chelsio/chcr_algo.c:2113:2: warning: this 'if' clause does not guard...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
head:   20b04c02bcb2d1e6a642bbe9e759157bb198499e
commit: e1a018e607a33dc9f987c761daf1792082fb9ca7 [147/154] crypto: chelsio - Remove dst sg size zero check
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        git checkout e1a018e607a33dc9f987c761daf1792082fb9ca7
        # save the attached .config to linux build tree
        make.cross ARCH=ia64 

All warnings (new ones prefixed by >>):

   drivers/crypto/chelsio/chcr_algo.c: In function 'create_authenc_wr':
>> drivers/crypto/chelsio/chcr_algo.c:2113:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if (error)
     ^~
   drivers/crypto/chelsio/chcr_algo.c:2115:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
      dnents = sg_nents_xlen(req->dst, assoclen, CHCR_DST_SG_SIZE, 0);
      ^~~~~~

vim +/if +2113 drivers/crypto/chelsio/chcr_algo.c

2debd3325 Harsh Jain        2016-11-29  2078  
2debd3325 Harsh Jain        2016-11-29  2079  static struct sk_buff *create_authenc_wr(struct aead_request *req,
2debd3325 Harsh Jain        2016-11-29  2080  					 unsigned short qid,
2debd3325 Harsh Jain        2016-11-29  2081  					 int size,
2debd3325 Harsh Jain        2016-11-29  2082  					 unsigned short op_type)
324429d74 Hariprasad Shenai 2016-08-17  2083  {
2debd3325 Harsh Jain        2016-11-29  2084  	struct crypto_aead *tfm = crypto_aead_reqtfm(req);
2f47d5804 Harsh Jain        2017-10-08  2085  	struct chcr_aead_ctx *aeadctx = AEAD_CTX(a_ctx(tfm));
2debd3325 Harsh Jain        2016-11-29  2086  	struct chcr_authenc_ctx *actx = AUTHENC_CTX(aeadctx);
2debd3325 Harsh Jain        2016-11-29  2087  	struct chcr_aead_reqctx *reqctx = aead_request_ctx(req);
2debd3325 Harsh Jain        2016-11-29  2088  	struct sk_buff *skb = NULL;
2debd3325 Harsh Jain        2016-11-29  2089  	struct chcr_wr *chcr_req;
2debd3325 Harsh Jain        2016-11-29  2090  	struct cpl_rx_phys_dsgl *phys_cpl;
2f47d5804 Harsh Jain        2017-10-08  2091  	struct ulptx_sgl *ulptx;
2f47d5804 Harsh Jain        2017-10-08  2092  	unsigned int transhdr_len;
3d64bd670 Harsh Jain        2018-01-11  2093  	unsigned int dst_size = 0, temp, subtype = get_aead_subtype(tfm);
2f47d5804 Harsh Jain        2017-10-08  2094  	unsigned int   kctx_len = 0, dnents;
2debd3325 Harsh Jain        2016-11-29  2095  	unsigned int  assoclen = req->assoclen;
2debd3325 Harsh Jain        2016-11-29  2096  	unsigned int  authsize = crypto_aead_authsize(tfm);
2f47d5804 Harsh Jain        2017-10-08  2097  	int error = -EINVAL;
2debd3325 Harsh Jain        2016-11-29  2098  	int null = 0;
2debd3325 Harsh Jain        2016-11-29  2099  	gfp_t flags = req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL :
2debd3325 Harsh Jain        2016-11-29  2100  		GFP_ATOMIC;
2f47d5804 Harsh Jain        2017-10-08  2101  	struct adapter *adap = padap(a_ctx(tfm)->dev);
2debd3325 Harsh Jain        2016-11-29  2102  
2f47d5804 Harsh Jain        2017-10-08  2103  	if (req->cryptlen == 0)
2f47d5804 Harsh Jain        2017-10-08  2104  		return NULL;
2debd3325 Harsh Jain        2016-11-29  2105  
2f47d5804 Harsh Jain        2017-10-08  2106  	reqctx->b0_dma = 0;
3d64bd670 Harsh Jain        2018-01-11  2107  	if (subtype == CRYPTO_ALG_SUB_TYPE_CBC_NULL ||
3d64bd670 Harsh Jain        2018-01-11  2108  	subtype == CRYPTO_ALG_SUB_TYPE_CTR_NULL) {
2debd3325 Harsh Jain        2016-11-29  2109  		null = 1;
2debd3325 Harsh Jain        2016-11-29  2110  		assoclen = 0;
324429d74 Hariprasad Shenai 2016-08-17  2111  	}
2f47d5804 Harsh Jain        2017-10-08  2112  	error = chcr_aead_common_init(req, op_type);
2f47d5804 Harsh Jain        2017-10-08 @2113  	if (error)
2f47d5804 Harsh Jain        2017-10-08  2114  		return ERR_PTR(error);
2f47d5804 Harsh Jain        2017-10-08  2115  		dnents = sg_nents_xlen(req->dst, assoclen, CHCR_DST_SG_SIZE, 0);
2f47d5804 Harsh Jain        2017-10-08  2116  		dnents += sg_nents_xlen(req->dst, req->cryptlen +
2f47d5804 Harsh Jain        2017-10-08  2117  			(op_type ? -authsize : authsize), CHCR_DST_SG_SIZE,
2f47d5804 Harsh Jain        2017-10-08  2118  			req->assoclen);
2f47d5804 Harsh Jain        2017-10-08  2119  		dnents += MIN_AUTH_SG; // For IV
2f47d5804 Harsh Jain        2017-10-08  2120  
2f47d5804 Harsh Jain        2017-10-08  2121  	dst_size = get_space_for_phys_dsgl(dnents);
2debd3325 Harsh Jain        2016-11-29  2122  	kctx_len = (ntohl(KEY_CONTEXT_CTX_LEN_V(aeadctx->key_ctx_hdr)) << 4)
2debd3325 Harsh Jain        2016-11-29  2123  		- sizeof(chcr_req->key_ctx);
2debd3325 Harsh Jain        2016-11-29  2124  	transhdr_len = CIPHER_TRANSHDR_SIZE(kctx_len, dst_size);
2f47d5804 Harsh Jain        2017-10-08  2125  	reqctx->imm = (transhdr_len + assoclen + IV + req->cryptlen) <
2f47d5804 Harsh Jain        2017-10-08  2126  			SGE_MAX_WR_LEN;
2f47d5804 Harsh Jain        2017-10-08  2127  	temp = reqctx->imm ? (DIV_ROUND_UP((assoclen + IV + req->cryptlen), 16)
2f47d5804 Harsh Jain        2017-10-08  2128  			* 16) : (sgl_len(reqctx->src_nents + reqctx->aad_nents
2f47d5804 Harsh Jain        2017-10-08  2129  			+ MIN_GCM_SG) * 8);
2f47d5804 Harsh Jain        2017-10-08  2130  	transhdr_len += temp;
2f47d5804 Harsh Jain        2017-10-08  2131  	transhdr_len = DIV_ROUND_UP(transhdr_len, 16) * 16;
2f47d5804 Harsh Jain        2017-10-08  2132  
2f47d5804 Harsh Jain        2017-10-08  2133  	if (chcr_aead_need_fallback(req, dnents, T6_MAX_AAD_SIZE,
2f47d5804 Harsh Jain        2017-10-08  2134  				    transhdr_len, op_type)) {
ee0863ba1 Harsh Jain        2017-06-15  2135  		atomic_inc(&adap->chcr_stats.fallback);
2f47d5804 Harsh Jain        2017-10-08  2136  		chcr_aead_dma_unmap(&ULD_CTX(a_ctx(tfm))->lldi.pdev->dev, req,
2f47d5804 Harsh Jain        2017-10-08  2137  				    op_type);
0e93708da Harsh Jain        2017-04-10  2138  		return ERR_PTR(chcr_aead_fallback(req, op_type));
0e93708da Harsh Jain        2017-04-10  2139  	}
2f47d5804 Harsh Jain        2017-10-08  2140  	skb = alloc_skb(SGE_MAX_WR_LEN, flags);
5fe8c7117 Harsh Jain        2017-06-15  2141  	if (!skb) {
5fe8c7117 Harsh Jain        2017-06-15  2142  		error = -ENOMEM;
2debd3325 Harsh Jain        2016-11-29  2143  		goto err;
5fe8c7117 Harsh Jain        2017-06-15  2144  	}
2debd3325 Harsh Jain        2016-11-29  2145  
de77b966c yuan linyu        2017-06-18  2146  	chcr_req = __skb_put_zero(skb, transhdr_len);
2debd3325 Harsh Jain        2016-11-29  2147  
2f47d5804 Harsh Jain        2017-10-08  2148  	temp  = (op_type == CHCR_ENCRYPT_OP) ? 0 : authsize;
2debd3325 Harsh Jain        2016-11-29  2149  
2debd3325 Harsh Jain        2016-11-29  2150  	/*
2debd3325 Harsh Jain        2016-11-29  2151  	 * Input order	is AAD,IV and Payload. where IV should be included as
2debd3325 Harsh Jain        2016-11-29  2152  	 * the part of authdata. All other fields should be filled according
2debd3325 Harsh Jain        2016-11-29  2153  	 * to the hardware spec
2debd3325 Harsh Jain        2016-11-29  2154  	 */
2debd3325 Harsh Jain        2016-11-29  2155  	chcr_req->sec_cpl.op_ivinsrtofst =
2f47d5804 Harsh Jain        2017-10-08  2156  		FILL_SEC_CPL_OP_IVINSR(a_ctx(tfm)->dev->rx_channel_id, 2,
2f47d5804 Harsh Jain        2017-10-08  2157  				       assoclen + 1);
2f47d5804 Harsh Jain        2017-10-08  2158  	chcr_req->sec_cpl.pldlen = htonl(assoclen + IV + req->cryptlen);
2debd3325 Harsh Jain        2016-11-29  2159  	chcr_req->sec_cpl.aadstart_cipherstop_hi = FILL_SEC_CPL_CIPHERSTOP_HI(
2debd3325 Harsh Jain        2016-11-29  2160  					assoclen ? 1 : 0, assoclen,
2f47d5804 Harsh Jain        2017-10-08  2161  					assoclen + IV + 1,
2f47d5804 Harsh Jain        2017-10-08  2162  					(temp & 0x1F0) >> 4);
2debd3325 Harsh Jain        2016-11-29  2163  	chcr_req->sec_cpl.cipherstop_lo_authinsert = FILL_SEC_CPL_AUTHINSERT(
2f47d5804 Harsh Jain        2017-10-08  2164  					temp & 0xF,
2f47d5804 Harsh Jain        2017-10-08  2165  					null ? 0 : assoclen + IV + 1,
2f47d5804 Harsh Jain        2017-10-08  2166  					temp, temp);
3d64bd670 Harsh Jain        2018-01-11  2167  	if (subtype == CRYPTO_ALG_SUB_TYPE_CTR_NULL ||
3d64bd670 Harsh Jain        2018-01-11  2168  	    subtype == CRYPTO_ALG_SUB_TYPE_CTR_SHA)
3d64bd670 Harsh Jain        2018-01-11  2169  		temp = CHCR_SCMD_CIPHER_MODE_AES_CTR;
3d64bd670 Harsh Jain        2018-01-11  2170  	else
3d64bd670 Harsh Jain        2018-01-11  2171  		temp = CHCR_SCMD_CIPHER_MODE_AES_CBC;
2debd3325 Harsh Jain        2016-11-29  2172  	chcr_req->sec_cpl.seqno_numivs = FILL_SEC_CPL_SCMD0_SEQNO(op_type,
2debd3325 Harsh Jain        2016-11-29  2173  					(op_type == CHCR_ENCRYPT_OP) ? 1 : 0,
3d64bd670 Harsh Jain        2018-01-11  2174  					temp,
2debd3325 Harsh Jain        2016-11-29  2175  					actx->auth_mode, aeadctx->hmac_ctrl,
2f47d5804 Harsh Jain        2017-10-08  2176  					IV >> 1);
2debd3325 Harsh Jain        2016-11-29  2177  	chcr_req->sec_cpl.ivgen_hdrlen =  FILL_SEC_CPL_IVGEN_HDRLEN(0, 0, 1,
2f47d5804 Harsh Jain        2017-10-08  2178  					 0, 0, dst_size);
2debd3325 Harsh Jain        2016-11-29  2179  
2debd3325 Harsh Jain        2016-11-29  2180  	chcr_req->key_ctx.ctx_hdr = aeadctx->key_ctx_hdr;
3d64bd670 Harsh Jain        2018-01-11  2181  	if (op_type == CHCR_ENCRYPT_OP ||
3d64bd670 Harsh Jain        2018-01-11  2182  		subtype == CRYPTO_ALG_SUB_TYPE_CTR_SHA ||
3d64bd670 Harsh Jain        2018-01-11  2183  		subtype == CRYPTO_ALG_SUB_TYPE_CTR_NULL)
2debd3325 Harsh Jain        2016-11-29  2184  		memcpy(chcr_req->key_ctx.key, aeadctx->key,
2debd3325 Harsh Jain        2016-11-29  2185  		       aeadctx->enckey_len);
2debd3325 Harsh Jain        2016-11-29  2186  	else
2debd3325 Harsh Jain        2016-11-29  2187  		memcpy(chcr_req->key_ctx.key, actx->dec_rrkey,
2debd3325 Harsh Jain        2016-11-29  2188  		       aeadctx->enckey_len);
2debd3325 Harsh Jain        2016-11-29  2189  
2debd3325 Harsh Jain        2016-11-29  2190  	memcpy(chcr_req->key_ctx.key + (DIV_ROUND_UP(aeadctx->enckey_len, 16) <<
2debd3325 Harsh Jain        2016-11-29  2191  					4), actx->h_iopad, kctx_len -
2debd3325 Harsh Jain        2016-11-29  2192  				(DIV_ROUND_UP(aeadctx->enckey_len, 16) << 4));
3d64bd670 Harsh Jain        2018-01-11  2193  	if (subtype == CRYPTO_ALG_SUB_TYPE_CTR_SHA ||
3d64bd670 Harsh Jain        2018-01-11  2194  	    subtype == CRYPTO_ALG_SUB_TYPE_CTR_NULL) {
3d64bd670 Harsh Jain        2018-01-11  2195  		memcpy(reqctx->iv, aeadctx->nonce, CTR_RFC3686_NONCE_SIZE);
3d64bd670 Harsh Jain        2018-01-11  2196  		memcpy(reqctx->iv + CTR_RFC3686_NONCE_SIZE, req->iv,
3d64bd670 Harsh Jain        2018-01-11  2197  				CTR_RFC3686_IV_SIZE);
3d64bd670 Harsh Jain        2018-01-11  2198  		*(__be32 *)(reqctx->iv + CTR_RFC3686_NONCE_SIZE +
3d64bd670 Harsh Jain        2018-01-11  2199  			CTR_RFC3686_IV_SIZE) = cpu_to_be32(1);
3d64bd670 Harsh Jain        2018-01-11  2200  	} else {
2f47d5804 Harsh Jain        2017-10-08  2201  		memcpy(reqctx->iv, req->iv, IV);
3d64bd670 Harsh Jain        2018-01-11  2202  	}
2debd3325 Harsh Jain        2016-11-29  2203  	phys_cpl = (struct cpl_rx_phys_dsgl *)((u8 *)(chcr_req + 1) + kctx_len);
2f47d5804 Harsh Jain        2017-10-08  2204  	ulptx = (struct ulptx_sgl *)((u8 *)(phys_cpl + 1) + dst_size);
2f47d5804 Harsh Jain        2017-10-08  2205  	chcr_add_aead_dst_ent(req, phys_cpl, assoclen, op_type, qid);
2f47d5804 Harsh Jain        2017-10-08  2206  	chcr_add_aead_src_ent(req, ulptx, assoclen, op_type);
ee0863ba1 Harsh Jain        2017-06-15  2207  	atomic_inc(&adap->chcr_stats.cipher_rqst);
2f47d5804 Harsh Jain        2017-10-08  2208  	temp = sizeof(struct cpl_rx_phys_dsgl) + dst_size +
2f47d5804 Harsh Jain        2017-10-08  2209  		kctx_len + (reqctx->imm ? (assoclen + IV + req->cryptlen) : 0);
2f47d5804 Harsh Jain        2017-10-08  2210  	create_wreq(a_ctx(tfm), chcr_req, &req->base, reqctx->imm, size,
2f47d5804 Harsh Jain        2017-10-08  2211  		   transhdr_len, temp, 0);
2debd3325 Harsh Jain        2016-11-29  2212  	reqctx->skb = skb;
2f47d5804 Harsh Jain        2017-10-08  2213  	reqctx->op = op_type;
2debd3325 Harsh Jain        2016-11-29  2214  
2debd3325 Harsh Jain        2016-11-29  2215  	return skb;
2debd3325 Harsh Jain        2016-11-29  2216  err:
2f47d5804 Harsh Jain        2017-10-08  2217  	chcr_aead_dma_unmap(&ULD_CTX(a_ctx(tfm))->lldi.pdev->dev, req,
2f47d5804 Harsh Jain        2017-10-08  2218  			    op_type);
2f47d5804 Harsh Jain        2017-10-08  2219  
5fe8c7117 Harsh Jain        2017-06-15  2220  	return ERR_PTR(error);
324429d74 Hariprasad Shenai 2016-08-17  2221  }
2debd3325 Harsh Jain        2016-11-29  2222  

:::::: The code at line 2113 was first introduced by commit
:::::: 2f47d58043110b0aeac1952494db668fc0fc7c0a crypto: chelsio - Move DMA un/mapping to chcr from lld cxgb4 driver

:::::: TO: Harsh Jain <harsh@xxxxxxxxxxx>
:::::: CC: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux