From patchwork Sun Jul 30 16:15:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 108955 Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp2747518obm; Sun, 30 Jul 2017 09:15:35 -0700 (PDT) X-Received: by 10.99.104.3 with SMTP id d3mr13474702pgc.278.1501431335849; Sun, 30 Jul 2017 09:15:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501431335; cv=none; d=google.com; s=arc-20160816; b=Fl/FmMUhLoRc3XFXYp0D5QfLPw3Znznhw281ZvgUtbUuncGN38LJOt6eO8c+uAr75Z 8KMWAnn/FXVedC0hxTRkV8qtbwKRqpA+WOy1x/oQ4pgY5E4OuAs6bdsN8VzwUAHgwCbc 7uO0VwlK4W555apuz2LZaXTrgFxDFykEuloFxJraqfDDgxv5jupeBP10LhKKYsBa8kgL HCqGxtK8R9GbgYJGSl27aRsdvItQP+FdfyF+8URfam25ulh6kEDQJSg6/9zYPzRi2NSx /4UiqZbyaIb4jVfcPZtiZFfP7jvXqG53dasWAG5eVkVTJtYe7rWlHqypNlbvEjt092Ov qQxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=IK01l6N7/pDecYx/LyijxIvfzyRE7Io4Z7Pz2TzpH9c=; b=OX85jIEVywESLtBWpAiHkxvD5TJacpUWpJ41M8NVByhlN4VHMe5BypoSIVBa3F4b0e FckaLHgy2Wf5Z3OyktpD1VHgyUlyY49lzpP4BGth0D7UPO19KdiUPr28ART8vW28Ikpu YEN70UF1cVWKe/mVVPUGjYwYwl+AuErPKuQ9EESiXZex25dbxvyEji5rt1iyT+fOgz6j ADhQVAkoGTBUYjvxmLXyipxOUbo2qrr5GZwiAvdeK+3zJpV1+oEiC/vuGTWhG74E/wTr PeeGaYYiwMjkcttwCASHW8DbKKy8po6c7FF9fNauUe3Xdl0+2eLjYwjXHi0gItWuGgpp wuDg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o11si12587120pgq.683.2017.07.30.09.15.35; Sun, 30 Jul 2017 09:15:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754241AbdG3QPW (ORCPT + 26 others); Sun, 30 Jul 2017 12:15:22 -0400 Received: from foss.arm.com ([217.140.101.70]:42980 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754159AbdG3QPR (ORCPT ); Sun, 30 Jul 2017 12:15:17 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7918E13D5; Sun, 30 Jul 2017 09:15:17 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AFA303F540; Sun, 30 Jul 2017 09:15:15 -0700 (PDT) From: Gilad Ben-Yossef To: Greg Kroah-Hartman , linux-crypto@vger.kernel.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v2 1/6] staging: ccree: fix split strings Date: Sun, 30 Jul 2017 19:15:03 +0300 Message-Id: <1501431309-27705-2-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1501431309-27705-1-git-send-email-gilad@benyossef.com> References: <1501431309-27705-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix strings in log messages being split across lines and the resulting alignment issues when being fixed. Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_aead.c | 9 ++-- drivers/staging/ccree/ssi_buffer_mgr.c | 86 ++++++++++++++------------------- drivers/staging/ccree/ssi_cipher.c | 27 +++++------ drivers/staging/ccree/ssi_driver.c | 4 +- drivers/staging/ccree/ssi_hash.c | 43 ++++++++--------- drivers/staging/ccree/ssi_ivgen.c | 8 +-- drivers/staging/ccree/ssi_request_mgr.c | 13 ++--- 7 files changed, 81 insertions(+), 109 deletions(-) -- 2.1.4 diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c index f5ca0e3..d8f2249 100644 --- a/drivers/staging/ccree/ssi_aead.c +++ b/drivers/staging/ccree/ssi_aead.c @@ -240,9 +240,8 @@ static void ssi_aead_complete(struct device *dev, void *ssi_req, void __iomem *c if (areq_ctx->gen_ctx.op_type == DRV_CRYPTO_DIRECTION_DECRYPT) { if (memcmp(areq_ctx->mac_buf, areq_ctx->icv_virt_addr, ctx->authsize) != 0) { - SSI_LOG_DEBUG("Payload authentication failure, " - "(auth-size=%d, cipher=%d).\n", - ctx->authsize, ctx->cipher_mode); + SSI_LOG_DEBUG("Payload authentication failure, (auth-size=%d, cipher=%d).\n", + ctx->authsize, ctx->cipher_mode); /* In case of payload authentication failure, MUST NOT * revealed the decrypted message --> zero its memory. */ @@ -455,8 +454,8 @@ ssi_get_plain_hmac_key(struct crypto_aead *tfm, const u8 *key, unsigned int keyl if (likely(keylen != 0)) { key_dma_addr = dma_map_single(dev, (void *)key, keylen, DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, key_dma_addr))) { - SSI_LOG_ERR("Mapping key va=0x%p len=%u for" - " DMA failed\n", key, keylen); + SSI_LOG_ERR("Mapping key va=0x%p len=%u for DMA failed\n", + key, keylen); return -ENOMEM; } if (keylen > blocksize) { diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c b/drivers/staging/ccree/ssi_buffer_mgr.c index 6393609..d7ce293 100644 --- a/drivers/staging/ccree/ssi_buffer_mgr.c +++ b/drivers/staging/ccree/ssi_buffer_mgr.c @@ -82,8 +82,8 @@ static unsigned int ssi_buffer_mgr_get_sgl_nents( while (nbytes != 0) { if (sg_is_chain(sg_list)) { - SSI_LOG_ERR("Unexpected chained entry " - "in sg (entry =0x%X)\n", nents); + SSI_LOG_ERR("Unexpected chained entry in sg (entry =0x%X)\n", + nents); BUG(); } if (sg_list->length != 0) { @@ -259,11 +259,9 @@ static int ssi_buffer_mgr_generate_mlli( /* Set MLLI size for the bypass operation */ mlli_params->mlli_len = (total_nents * LLI_ENTRY_BYTE_SIZE); - SSI_LOG_DEBUG("MLLI params: " - "virt_addr=%pK dma_addr=%pad mlli_len=0x%X\n", - mlli_params->mlli_virt_addr, - mlli_params->mlli_dma_addr, - mlli_params->mlli_len); + SSI_LOG_DEBUG("MLLI params: virt_addr=%pK dma_addr=%pad mlli_len=0x%X\n", + mlli_params->mlli_virt_addr, mlli_params->mlli_dma_addr, + mlli_params->mlli_len); build_mlli_exit: return rc; @@ -276,9 +274,8 @@ static inline void ssi_buffer_mgr_add_buffer_entry( { unsigned int index = sgl_data->num_of_buffers; - SSI_LOG_DEBUG("index=%u single_buff=%pad " - "buffer_len=0x%08X is_last=%d\n", - index, buffer_dma, buffer_len, is_last_entry); + SSI_LOG_DEBUG("index=%u single_buff=%pad buffer_len=0x%08X is_last=%d\n", + index, buffer_dma, buffer_len, is_last_entry); sgl_data->nents[index] = 1; sgl_data->entry[index].buffer_dma = buffer_dma; sgl_data->offset[index] = 0; @@ -359,8 +356,7 @@ static int ssi_buffer_mgr_map_scatterlist( SSI_LOG_ERR("dma_map_sg() single buffer failed\n"); return -ENOMEM; } - SSI_LOG_DEBUG("Mapped sg: dma_address=%pad " - "page=%p addr=%pK offset=%u " + SSI_LOG_DEBUG("Mapped sg: dma_address=%pad page=%p addr=%pK offset=%u " "length=%u\n", sg_dma_address(sg), sg_page(sg), @@ -419,12 +415,10 @@ ssi_aead_handle_config_buf(struct device *dev, sg_init_one(&areq_ctx->ccm_adata_sg, config_data, AES_BLOCK_SIZE + areq_ctx->ccm_hdr_size); if (unlikely(dma_map_sg(dev, &areq_ctx->ccm_adata_sg, 1, DMA_TO_DEVICE) != 1)) { - SSI_LOG_ERR("dma_map_sg() " - "config buffer failed\n"); + SSI_LOG_ERR("dma_map_sg() config buffer failed\n"); return -ENOMEM; } - SSI_LOG_DEBUG("Mapped curr_buff: dma_address=%pad " - "page=%p addr=%pK " + SSI_LOG_DEBUG("Mapped curr_buff: dma_address=%pad page=%p addr=%pK " "offset=%u length=%u\n", sg_dma_address(&areq_ctx->ccm_adata_sg), sg_page(&areq_ctx->ccm_adata_sg), @@ -452,12 +446,10 @@ static inline int ssi_ahash_handle_curr_buf(struct device *dev, sg_init_one(areq_ctx->buff_sg, curr_buff, curr_buff_cnt); if (unlikely(dma_map_sg(dev, areq_ctx->buff_sg, 1, DMA_TO_DEVICE) != 1)) { - SSI_LOG_ERR("dma_map_sg() " - "src buffer failed\n"); + SSI_LOG_ERR("dma_map_sg() src buffer failed\n"); return -ENOMEM; } - SSI_LOG_DEBUG("Mapped curr_buff: dma_address=%pad " - "page=%p addr=%pK " + SSI_LOG_DEBUG("Mapped curr_buff: dma_address=%pad page=%p addr=%pK " "offset=%u length=%u\n", sg_dma_address(areq_ctx->buff_sg), sg_page(areq_ctx->buff_sg), @@ -539,8 +531,8 @@ int ssi_buffer_mgr_map_blkcipher_request( DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, req_ctx->gen_ctx.iv_dma_addr))) { - SSI_LOG_ERR("Mapping iv %u B at va=%pK " - "for DMA failed\n", ivsize, info); + SSI_LOG_ERR("Mapping iv %u B at va=%pK for DMA failed\n", + ivsize, info); return -ENOMEM; } SSI_LOG_DEBUG("Mapped iv %u B at va=%pK to dma=%pad\n", @@ -1340,9 +1332,9 @@ int ssi_buffer_mgr_map_aead_request( DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, areq_ctx->ccm_iv0_dma_addr))) { - SSI_LOG_ERR("Mapping mac_buf %u B at va=%pK " - "for DMA failed\n", AES_BLOCK_SIZE, - (areq_ctx->ccm_config + CCM_CTR_COUNT_0_OFFSET)); + SSI_LOG_ERR("Mapping mac_buf %u B at va=%pK for DMA failed\n", + AES_BLOCK_SIZE, (areq_ctx->ccm_config + + CCM_CTR_COUNT_0_OFFSET)); areq_ctx->ccm_iv0_dma_addr = 0; rc = -ENOMEM; goto aead_map_failure; @@ -1385,9 +1377,8 @@ int ssi_buffer_mgr_map_aead_request( DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, areq_ctx->gcm_iv_inc1_dma_addr))) { - SSI_LOG_ERR("Mapping gcm_iv_inc1 %u B at va=%pK " - "for DMA failed\n", AES_BLOCK_SIZE, - (areq_ctx->gcm_iv_inc1)); + SSI_LOG_ERR("Mapping gcm_iv_inc1 %u B at va=%pK for DMA failed\n", + AES_BLOCK_SIZE, (areq_ctx->gcm_iv_inc1)); areq_ctx->gcm_iv_inc1_dma_addr = 0; rc = -ENOMEM; goto aead_map_failure; @@ -1399,9 +1390,8 @@ int ssi_buffer_mgr_map_aead_request( DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, areq_ctx->gcm_iv_inc2_dma_addr))) { - SSI_LOG_ERR("Mapping gcm_iv_inc2 %u B at va=%pK " - "for DMA failed\n", AES_BLOCK_SIZE, - (areq_ctx->gcm_iv_inc2)); + SSI_LOG_ERR("Mapping gcm_iv_inc2 %u B at va=%pK for DMA failed\n", + AES_BLOCK_SIZE, (areq_ctx->gcm_iv_inc2)); areq_ctx->gcm_iv_inc2_dma_addr = 0; rc = -ENOMEM; goto aead_map_failure; @@ -1507,8 +1497,7 @@ int ssi_buffer_mgr_map_hash_request_final( u32 dummy = 0; u32 mapped_nents = 0; - SSI_LOG_DEBUG(" final params : curr_buff=%pK " - "curr_buff_cnt=0x%X nbytes = 0x%X " + SSI_LOG_DEBUG(" final params : curr_buff=%pK curr_buff_cnt=0x%X nbytes = 0x%X " "src=%pK curr_index=%u\n", curr_buff, *curr_buff_cnt, nbytes, src, areq_ctx->buff_index); @@ -1604,8 +1593,7 @@ int ssi_buffer_mgr_map_hash_request_update( u32 dummy = 0; u32 mapped_nents = 0; - SSI_LOG_DEBUG(" update params : curr_buff=%pK " - "curr_buff_cnt=0x%X nbytes=0x%X " + SSI_LOG_DEBUG(" update params : curr_buff=%pK curr_buff_cnt=0x%X nbytes=0x%X " "src=%pK curr_index=%u\n", curr_buff, *curr_buff_cnt, nbytes, src, areq_ctx->buff_index); @@ -1617,10 +1605,9 @@ int ssi_buffer_mgr_map_hash_request_update( areq_ctx->in_nents = 0; if (unlikely(total_in_len < block_size)) { - SSI_LOG_DEBUG(" less than one block: curr_buff=%pK " - "*curr_buff_cnt=0x%X copy_to=%pK\n", - curr_buff, *curr_buff_cnt, - &curr_buff[*curr_buff_cnt]); + SSI_LOG_DEBUG(" less than one block: curr_buff=%pK *curr_buff_cnt=0x%X copy_to=%pK\n", + curr_buff, *curr_buff_cnt, + &curr_buff[*curr_buff_cnt]); areq_ctx->in_nents = ssi_buffer_mgr_get_sgl_nents(src, nbytes, @@ -1636,16 +1623,14 @@ int ssi_buffer_mgr_map_hash_request_update( /* update data len */ update_data_len = total_in_len - *next_buff_cnt; - SSI_LOG_DEBUG(" temp length : *next_buff_cnt=0x%X " - "update_data_len=0x%X\n", - *next_buff_cnt, update_data_len); + SSI_LOG_DEBUG(" temp length : *next_buff_cnt=0x%X update_data_len=0x%X\n", + *next_buff_cnt, update_data_len); /* Copy the new residue to next buffer */ if (*next_buff_cnt != 0) { - SSI_LOG_DEBUG(" handle residue: next buff %pK skip data %u" - " residue %u\n", next_buff, - (update_data_len - *curr_buff_cnt), - *next_buff_cnt); + SSI_LOG_DEBUG(" handle residue: next buff %pK skip data %u residue %u\n", + next_buff, (update_data_len - *curr_buff_cnt), + *next_buff_cnt); ssi_buffer_mgr_copy_scatterlist_portion(next_buff, src, (update_data_len - *curr_buff_cnt), nbytes, SSI_SG_TO_BUF); @@ -1743,11 +1728,10 @@ void ssi_buffer_mgr_unmap_hash_request( } if (*prev_len != 0) { - SSI_LOG_DEBUG("Unmapped buffer: areq_ctx->buff_sg=%pK" - " dma=%pad len 0x%X\n", - sg_virt(areq_ctx->buff_sg), - sg_dma_address(areq_ctx->buff_sg), - sg_dma_len(areq_ctx->buff_sg)); + SSI_LOG_DEBUG("Unmapped buffer: areq_ctx->buff_sg=%pK dma=%pad len 0x%X\n", + sg_virt(areq_ctx->buff_sg), + sg_dma_address(areq_ctx->buff_sg), + sg_dma_len(areq_ctx->buff_sg)); dma_unmap_sg(dev, areq_ctx->buff_sg, 1, DMA_TO_DEVICE); if (!do_revert) { /* clean the previous data length for update operation */ diff --git a/drivers/staging/ccree/ssi_cipher.c b/drivers/staging/ccree/ssi_cipher.c index 6219a92..068b10b 100644 --- a/drivers/staging/ccree/ssi_cipher.c +++ b/drivers/staging/ccree/ssi_cipher.c @@ -636,11 +636,10 @@ ssi_blkcipher_create_data_desc( (*seq_size)++; } else { /* bypass */ - SSI_LOG_DEBUG(" bypass params addr %pad " - "length 0x%X addr 0x%08X\n", - req_ctx->mlli_params.mlli_dma_addr, - req_ctx->mlli_params.mlli_len, - (unsigned int)ctx_p->drvdata->mlli_sram_addr); + SSI_LOG_DEBUG(" bypass params addr %pad length 0x%X addr 0x%08X\n", + req_ctx->mlli_params.mlli_dma_addr, + req_ctx->mlli_params.mlli_len, + (unsigned int)ctx_p->drvdata->mlli_sram_addr); hw_desc_init(&desc[*seq_size]); set_din_type(&desc[*seq_size], DMA_DLLI, req_ctx->mlli_params.mlli_dma_addr, @@ -656,21 +655,19 @@ ssi_blkcipher_create_data_desc( ctx_p->drvdata->mlli_sram_addr, req_ctx->in_mlli_nents, NS_BIT); if (req_ctx->out_nents == 0) { - SSI_LOG_DEBUG(" din/dout params addr 0x%08X " - "addr 0x%08X\n", - (unsigned int)ctx_p->drvdata->mlli_sram_addr, - (unsigned int)ctx_p->drvdata->mlli_sram_addr); + SSI_LOG_DEBUG(" din/dout params addr 0x%08X addr 0x%08X\n", + (unsigned int)ctx_p->drvdata->mlli_sram_addr, + (unsigned int)ctx_p->drvdata->mlli_sram_addr); set_dout_mlli(&desc[*seq_size], ctx_p->drvdata->mlli_sram_addr, req_ctx->in_mlli_nents, NS_BIT, (!areq ? 0 : 1)); } else { - SSI_LOG_DEBUG(" din/dout params " - "addr 0x%08X addr 0x%08X\n", - (unsigned int)ctx_p->drvdata->mlli_sram_addr, - (unsigned int)ctx_p->drvdata->mlli_sram_addr + - (u32)LLI_ENTRY_BYTE_SIZE * - req_ctx->in_nents); + SSI_LOG_DEBUG(" din/dout params addr 0x%08X addr 0x%08X\n", + (unsigned int)ctx_p->drvdata->mlli_sram_addr, + (unsigned int)ctx_p->drvdata->mlli_sram_addr + + (u32)LLI_ENTRY_BYTE_SIZE * + req_ctx->in_nents); set_dout_mlli(&desc[*seq_size], (ctx_p->drvdata->mlli_sram_addr + (LLI_ENTRY_BYTE_SIZE * diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index a4ab9ef..d104dbd 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -257,8 +257,8 @@ static int init_cc_resources(struct platform_device *plat_dev) /* Map registers space */ req_mem_cc_regs = request_mem_region(new_drvdata->res_mem->start, resource_size(new_drvdata->res_mem), "arm_cc7x_regs"); if (unlikely(!req_mem_cc_regs)) { - SSI_LOG_ERR("Couldn't allocate registers memory region at " - "0x%08X\n", (unsigned int)new_drvdata->res_mem->start); + SSI_LOG_ERR("Couldn't allocate registers memory region at 0x%08X\n", + (unsigned int)new_drvdata->res_mem->start); rc = -EBUSY; goto init_cc_res_err; } diff --git a/drivers/staging/ccree/ssi_hash.c b/drivers/staging/ccree/ssi_hash.c index 1a405bb..3a734df 100644 --- a/drivers/staging/ccree/ssi_hash.c +++ b/drivers/staging/ccree/ssi_hash.c @@ -138,10 +138,9 @@ static int ssi_hash_map_result(struct device *dev, digestsize); return -ENOMEM; } - SSI_LOG_DEBUG("Mapped digest result buffer %u B " - "at va=%pK to dma=%pad\n", - digestsize, state->digest_result_buff, - state->digest_result_dma_addr); + SSI_LOG_DEBUG("Mapped digest result buffer %u B at va=%pK to dma=%pad\n", + digestsize, state->digest_result_buff, + state->digest_result_dma_addr); return 0; } @@ -352,11 +351,10 @@ static void ssi_hash_unmap_result(struct device *dev, state->digest_result_dma_addr, digestsize, DMA_BIDIRECTIONAL); - SSI_LOG_DEBUG("unmpa digest result buffer " - "va (%pK) pa (%pad) len %u\n", - state->digest_result_buff, - state->digest_result_dma_addr, - digestsize); + SSI_LOG_DEBUG("unmpa digest result buffer va (%pK) pa (%pad) len %u\n", + state->digest_result_buff, + state->digest_result_dma_addr, + digestsize); memcpy(result, state->digest_result_buff, digestsize); @@ -994,13 +992,13 @@ static int ssi_hash_setkey(void *hash, keylen, DMA_TO_DEVICE); if (unlikely(dma_mapping_error(&ctx->drvdata->plat_dev->dev, ctx->key_params.key_dma_addr))) { - SSI_LOG_ERR("Mapping key va=0x%p len=%u for" - " DMA failed\n", key, keylen); + SSI_LOG_ERR("Mapping key va=0x%p len=%u for DMA failed\n", + key, keylen); return -ENOMEM; } - SSI_LOG_DEBUG("mapping key-buffer: key_dma_addr=%pad " - "keylen=%u\n", ctx->key_params.key_dma_addr, - ctx->key_params.keylen); + SSI_LOG_DEBUG("mapping key-buffer: key_dma_addr=%pad keylen=%u\n", + ctx->key_params.key_dma_addr, + ctx->key_params.keylen); if (keylen > blocksize) { /* Load hash initial state */ @@ -1176,14 +1174,13 @@ static int ssi_xcbc_setkey(struct crypto_ahash *ahash, keylen, DMA_TO_DEVICE); if (unlikely(dma_mapping_error(&ctx->drvdata->plat_dev->dev, ctx->key_params.key_dma_addr))) { - SSI_LOG_ERR("Mapping key va=0x%p len=%u for" - " DMA failed\n", key, keylen); + SSI_LOG_ERR("Mapping key va=0x%p len=%u for DMA failed\n", + key, keylen); return -ENOMEM; } - SSI_LOG_DEBUG("mapping key-buffer: key_dma_addr=%pad " - "keylen=%u\n", - ctx->key_params.key_dma_addr, - ctx->key_params.keylen); + SSI_LOG_DEBUG("mapping key-buffer: key_dma_addr=%pad keylen=%u\n", + ctx->key_params.key_dma_addr, + ctx->key_params.keylen); ctx->is_hmac = true; /* 1. Load the AES key */ @@ -1284,8 +1281,7 @@ static void ssi_hash_free_ctx(struct ssi_hash_ctx *ctx) if (ctx->digest_buff_dma_addr != 0) { dma_unmap_single(dev, ctx->digest_buff_dma_addr, sizeof(ctx->digest_buff), DMA_BIDIRECTIONAL); - SSI_LOG_DEBUG("Unmapped digest-buffer: " - "digest_buff_dma_addr=%pad\n", + SSI_LOG_DEBUG("Unmapped digest-buffer: digest_buff_dma_addr=%pad\n", ctx->digest_buff_dma_addr); ctx->digest_buff_dma_addr = 0; } @@ -1293,8 +1289,7 @@ static void ssi_hash_free_ctx(struct ssi_hash_ctx *ctx) dma_unmap_single(dev, ctx->opad_tmp_keys_dma_addr, sizeof(ctx->opad_tmp_keys_buff), DMA_BIDIRECTIONAL); - SSI_LOG_DEBUG("Unmapped opad-digest: " - "opad_tmp_keys_dma_addr=%pad\n", + SSI_LOG_DEBUG("Unmapped opad-digest: opad_tmp_keys_dma_addr=%pad\n", ctx->opad_tmp_keys_dma_addr); ctx->opad_tmp_keys_dma_addr = 0; } diff --git a/drivers/staging/ccree/ssi_ivgen.c b/drivers/staging/ccree/ssi_ivgen.c index 86364f8..bca44af 100644 --- a/drivers/staging/ccree/ssi_ivgen.c +++ b/drivers/staging/ccree/ssi_ivgen.c @@ -193,8 +193,8 @@ int ssi_ivgen_init(struct ssi_drvdata *drvdata) /* Allocate "this" context */ drvdata->ivgen_handle = kzalloc(sizeof(struct ssi_ivgen_ctx), GFP_KERNEL); if (!drvdata->ivgen_handle) { - SSI_LOG_ERR("Not enough memory to allocate IVGEN context " - "(%zu B)\n", sizeof(struct ssi_ivgen_ctx)); + SSI_LOG_ERR("Not enough memory to allocate IVGEN context (%zu B)\n", + sizeof(struct ssi_ivgen_ctx)); rc = -ENOMEM; goto out; } @@ -205,8 +205,8 @@ int ssi_ivgen_init(struct ssi_drvdata *drvdata) &ivgen_ctx->pool_meta_dma, GFP_KERNEL); if (!ivgen_ctx->pool_meta) { - SSI_LOG_ERR("Not enough memory to allocate DMA of pool_meta " - "(%u B)\n", SSI_IVPOOL_META_SIZE); + SSI_LOG_ERR("Not enough memory to allocate DMA of pool_meta (%u B)\n", + SSI_IVPOOL_META_SIZE); rc = -ENOMEM; goto out; } diff --git a/drivers/staging/ccree/ssi_request_mgr.c b/drivers/staging/ccree/ssi_request_mgr.c index 2eda82f..9a4bb5c 100644 --- a/drivers/staging/ccree/ssi_request_mgr.c +++ b/drivers/staging/ccree/ssi_request_mgr.c @@ -140,8 +140,8 @@ int request_mgr_init(struct ssi_drvdata *drvdata) &req_mgr_h->dummy_comp_buff_dma, GFP_KERNEL); if (!req_mgr_h->dummy_comp_buff) { - SSI_LOG_ERR("Not enough memory to allocate DMA (%zu) dropped " - "buffer\n", sizeof(u32)); + SSI_LOG_ERR("Not enough memory to allocate DMA (%zu) dropped buffer\n", + sizeof(u32)); rc = -ENOMEM; goto req_mgr_init_err; } @@ -238,12 +238,9 @@ static inline int request_mgr_queues_status_check( req_mgr_h->q_free_slots, total_seq_len); } /* No room in the HW queue try again later */ - SSI_LOG_DEBUG("HW FIFO full, timeout. req_queue_head=%d " - "sw_fifo_len=%d q_free_slots=%d total_seq_len=%d\n", - req_mgr_h->req_queue_head, - MAX_REQUEST_QUEUE_SIZE, - req_mgr_h->q_free_slots, - total_seq_len); + SSI_LOG_DEBUG("HW FIFO full, timeout. req_queue_head=%d sw_fifo_len=%d q_free_slots=%d total_seq_len=%d\n", + req_mgr_h->req_queue_head, MAX_REQUEST_QUEUE_SIZE, + req_mgr_h->q_free_slots, total_seq_len); return -EAGAIN; } From patchwork Sun Jul 30 16:15:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 108960 Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp2748392obm; Sun, 30 Jul 2017 09:16:38 -0700 (PDT) X-Received: by 10.101.90.136 with SMTP id c8mr8175889pgt.168.1501431398812; Sun, 30 Jul 2017 09:16:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501431398; cv=none; d=google.com; s=arc-20160816; b=tI+tvd7inMF4CVIEOLLLrXTL/LaGNMfGDWrZrcU9ZopUbVcCFM5cHbZxToPirUyhlZ 9t/JeMOfHglNMHUDdIW4zSJT0hjqSgllgle38sIuiQYlsC58eHI69WYpJUl+ITcf7o7j S4Vwd7CbEoGqoQDeX2m6Kkc3gQlKCRDczVPLYRkZ63N4xYVhcdVxesTWaDbd3SyM+O3g pEcADgtas+Dm79I3rLVuZX43UnymK0GhDqCOMG6V4jw3LDErflUjhFYHpfsr0kkVVuFw LuPxr2/moG3sgj7OEGpXWao0/DQHAMoXFpZUa+vIXD5WYwQmjntZ/0wZdgUnoR6LVHEt HZ4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=uzaGNx6gkezh/2ih4Q/LpR27eKoFu2mvkihJsjHzAsQ=; b=qnN9By5CwwIlGZvEI+wH2Sp4KijjDQ+Vw+r4D63sGiLgwairz8qPpv7HlFM30xDvT2 YufKyyD3aRluN2eCTsouyzY6+2fZUqMbv577O7i1TtLeBepAQnl9aijaePJP4OII2Sau sCY1H2uymBMtSNSYX7otmJO6m9R13qnr5kY7qKfHTmtUDl3OYj/UDwRtzm9xN8luJH2C Am6yDf+8UECbX8BogpS1hbtEIcFenisiaApfmVbWY36gFVIf8bns4Ohwy7CCMCsuf9Ay bOhY3ZXM5yc4FHMIV9nP9P92WSLZu04p8SWFvqDg053gDcW6onTkqILQsLrrQjNIXf3J +Xyg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i1si3212664plk.597.2017.07.30.09.16.38; Sun, 30 Jul 2017 09:16:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754399AbdG3QQf (ORCPT + 26 others); Sun, 30 Jul 2017 12:16:35 -0400 Received: from foss.arm.com ([217.140.101.70]:42990 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754224AbdG3QPV (ORCPT ); Sun, 30 Jul 2017 12:15:21 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CF76413D5; Sun, 30 Jul 2017 09:15:20 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0907A3F540; Sun, 30 Jul 2017 09:15:18 -0700 (PDT) From: Gilad Ben-Yossef To: Greg Kroah-Hartman , linux-crypto@vger.kernel.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v2 2/6] staging: ccree: kmalloc by sizeof var not type Date: Sun, 30 Jul 2017 19:15:04 +0300 Message-Id: <1501431309-27705-3-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1501431309-27705-1-git-send-email-gilad@benyossef.com> References: <1501431309-27705-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Change places where we alloc memory by sizeof type to sizeof var. Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_aead.c | 4 ++-- drivers/staging/ccree/ssi_cipher.c | 4 ++-- drivers/staging/ccree/ssi_driver.c | 2 +- drivers/staging/ccree/ssi_hash.c | 4 ++-- drivers/staging/ccree/ssi_ivgen.c | 2 +- drivers/staging/ccree/ssi_request_mgr.c | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) -- 2.1.4 diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c index d8f2249..a8cb432 100644 --- a/drivers/staging/ccree/ssi_aead.c +++ b/drivers/staging/ccree/ssi_aead.c @@ -2658,7 +2658,7 @@ static struct ssi_crypto_alg *ssi_aead_create_alg(struct ssi_alg_template *templ struct ssi_crypto_alg *t_alg; struct aead_alg *alg; - t_alg = kzalloc(sizeof(struct ssi_crypto_alg), GFP_KERNEL); + t_alg = kzalloc(sizeof(*t_alg), GFP_KERNEL); if (!t_alg) { SSI_LOG_ERR("failed to allocate t_alg\n"); return ERR_PTR(-ENOMEM); @@ -2713,7 +2713,7 @@ int ssi_aead_alloc(struct ssi_drvdata *drvdata) int rc = -ENOMEM; int alg; - aead_handle = kmalloc(sizeof(struct ssi_aead_handle), GFP_KERNEL); + aead_handle = kmalloc(sizeof(*aead_handle), GFP_KERNEL); if (!aead_handle) { rc = -ENOMEM; goto fail0; diff --git a/drivers/staging/ccree/ssi_cipher.c b/drivers/staging/ccree/ssi_cipher.c index 068b10b..d98178d 100644 --- a/drivers/staging/ccree/ssi_cipher.c +++ b/drivers/staging/ccree/ssi_cipher.c @@ -1215,7 +1215,7 @@ struct ssi_crypto_alg *ssi_ablkcipher_create_alg(struct ssi_alg_template *templa struct ssi_crypto_alg *t_alg; struct crypto_alg *alg; - t_alg = kzalloc(sizeof(struct ssi_crypto_alg), GFP_KERNEL); + t_alg = kzalloc(sizeof(*t_alg), GFP_KERNEL); if (!t_alg) { SSI_LOG_ERR("failed to allocate t_alg\n"); return ERR_PTR(-ENOMEM); @@ -1276,7 +1276,7 @@ int ssi_ablkcipher_alloc(struct ssi_drvdata *drvdata) int rc = -ENOMEM; int alg; - ablkcipher_handle = kmalloc(sizeof(struct ssi_blkcipher_handle), + ablkcipher_handle = kmalloc(sizeof(*ablkcipher_handle), GFP_KERNEL); if (!ablkcipher_handle) return -ENOMEM; diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index d104dbd..1cae2b7 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -223,7 +223,7 @@ static int init_cc_resources(struct platform_device *plat_dev) struct resource *req_mem_cc_regs = NULL; void __iomem *cc_base = NULL; bool irq_registered = false; - struct ssi_drvdata *new_drvdata = kzalloc(sizeof(struct ssi_drvdata), GFP_KERNEL); + struct ssi_drvdata *new_drvdata = kzalloc(sizeof(*new_drvdata), GFP_KERNEL); struct device *dev = &plat_dev->dev; struct device_node *np = dev->of_node; u32 signature_val; diff --git a/drivers/staging/ccree/ssi_hash.c b/drivers/staging/ccree/ssi_hash.c index 3a734df..6c08b1d 100644 --- a/drivers/staging/ccree/ssi_hash.c +++ b/drivers/staging/ccree/ssi_hash.c @@ -2055,7 +2055,7 @@ ssi_hash_create_alg(struct ssi_hash_template *template, bool keyed) struct crypto_alg *alg; struct ahash_alg *halg; - t_crypto_alg = kzalloc(sizeof(struct ssi_hash_alg), GFP_KERNEL); + t_crypto_alg = kzalloc(sizeof(*t_crypto_alg), GFP_KERNEL); if (!t_crypto_alg) { SSI_LOG_ERR("failed to allocate t_alg\n"); return ERR_PTR(-ENOMEM); @@ -2221,7 +2221,7 @@ int ssi_hash_alloc(struct ssi_drvdata *drvdata) int rc = 0; int alg; - hash_handle = kzalloc(sizeof(struct ssi_hash_handle), GFP_KERNEL); + hash_handle = kzalloc(sizeof(*hash_handle), GFP_KERNEL); if (!hash_handle) { SSI_LOG_ERR("kzalloc failed to allocate %zu B\n", sizeof(struct ssi_hash_handle)); diff --git a/drivers/staging/ccree/ssi_ivgen.c b/drivers/staging/ccree/ssi_ivgen.c index bca44af..93a2a94 100644 --- a/drivers/staging/ccree/ssi_ivgen.c +++ b/drivers/staging/ccree/ssi_ivgen.c @@ -191,7 +191,7 @@ int ssi_ivgen_init(struct ssi_drvdata *drvdata) int rc; /* Allocate "this" context */ - drvdata->ivgen_handle = kzalloc(sizeof(struct ssi_ivgen_ctx), GFP_KERNEL); + drvdata->ivgen_handle = kzalloc(sizeof(*drvdata->ivgen_handle), GFP_KERNEL); if (!drvdata->ivgen_handle) { SSI_LOG_ERR("Not enough memory to allocate IVGEN context (%zu B)\n", sizeof(struct ssi_ivgen_ctx)); diff --git a/drivers/staging/ccree/ssi_request_mgr.c b/drivers/staging/ccree/ssi_request_mgr.c index 9a4bb5c..cae9904 100644 --- a/drivers/staging/ccree/ssi_request_mgr.c +++ b/drivers/staging/ccree/ssi_request_mgr.c @@ -100,7 +100,7 @@ int request_mgr_init(struct ssi_drvdata *drvdata) struct ssi_request_mgr_handle *req_mgr_h; int rc = 0; - req_mgr_h = kzalloc(sizeof(struct ssi_request_mgr_handle), GFP_KERNEL); + req_mgr_h = kzalloc(sizeof(*req_mgr_h), GFP_KERNEL); if (!req_mgr_h) { rc = -ENOMEM; goto req_mgr_init_err; From patchwork Sun Jul 30 16:15:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 108956 Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp2747521obm; Sun, 30 Jul 2017 09:15:36 -0700 (PDT) X-Received: by 10.101.70.65 with SMTP id k1mr313900pgr.39.1501431336324; Sun, 30 Jul 2017 09:15:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501431336; cv=none; d=google.com; s=arc-20160816; b=co/h2gDR1yLROwdleLAB91AbmbKpnHcd329slrkf9CGECzPIB9adVI7VdEjdGZnELK qIjK/Gz0U1oxWcJFcMFtk3DnaQjzjAAY9Ffl93Gy793saKmX86mcDX2MMSiSqyKbVrsQ HAferRXxfzh7HNyGQC0NaYcKvUGRh2OsbynunCsqmdMcE5xIM8Ixn0TljdVOn72Hnqki FJ6mRQudbnaU59ijiHY6wr01csN+zeSA3bvunJLV8hLcwmGGcWR/GUgiawX2otD9KwHo gA9Pr6u/WKhlva8GDSlOr8QPQlpovNQpJDxHeWNnUWIBUjMf0IkGh2mmDlXU6Eqg5AKX KjWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=M2qe8fGIxBNn/s3iNB6AP154lF75SILfnxymUYwiPDU=; b=gmb5Kh9LPQ0cfeHXkBSegmU3qvIkbWdToIL9grqDLz4/BoX4GJ7YMT0PJT0tVyY7zu gLkTJQgQ6CEDZXsbbMYQQNIDtToy6HLJMNTN9aX85+kyOdCjiJnMdO/iM6jxNxhc8Ij3 JPvevU4UaDw4m/ScICQ38wxvQKR2lWuBtaMxSXEPNFdySRXiNUe/epeSd1b2Qyah3oCs RI+yp6rdaPa+oep0rA891o80F5wPnEZHRa3stvHphguY/eO8oCpJLijnv2zNATSzdJOA ScIWkvQBpnQ0MFJUMezZl52/C+gxbRmO6tQuqwMyBviw7RZO4PWkbNnyd41IGpISLhwr 30jQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o11si12587120pgq.683.2017.07.30.09.15.35; Sun, 30 Jul 2017 09:15:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754265AbdG3QP2 (ORCPT + 26 others); Sun, 30 Jul 2017 12:15:28 -0400 Received: from foss.arm.com ([217.140.101.70]:43004 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754243AbdG3QPY (ORCPT ); Sun, 30 Jul 2017 12:15:24 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5986913D5; Sun, 30 Jul 2017 09:15:24 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5C9453F540; Sun, 30 Jul 2017 09:15:22 -0700 (PDT) From: Gilad Ben-Yossef To: Greg Kroah-Hartman , linux-crypto@vger.kernel.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Cc: Ofir Drang , Suniel Mahesh Subject: [PATCH v2 3/6] staging: ccree: Replace kzalloc with devm_kzalloc Date: Sun, 30 Jul 2017 19:15:05 +0300 Message-Id: <1501431309-27705-4-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1501431309-27705-1-git-send-email-gilad@benyossef.com> References: <1501431309-27705-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suniel Mahesh It is recommended to use managed function devm_kzalloc, which simplifies driver cleanup paths and driver code. This patch does the following: (a) replace kzalloc with devm_kzalloc. (b) drop kfree(), because memory allocated with devm_kzalloc() is automatically freed on driver detach, otherwise it leads to a double free. (c) remove unnecessary blank lines. Signed-off-by: Suniel Mahesh [gby: rebase on top of latest coding style fixes changes] Acked-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_driver.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) -- 2.1.4 diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index 1cae2b7..97dfc2c 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -223,13 +223,15 @@ static int init_cc_resources(struct platform_device *plat_dev) struct resource *req_mem_cc_regs = NULL; void __iomem *cc_base = NULL; bool irq_registered = false; - struct ssi_drvdata *new_drvdata = kzalloc(sizeof(*new_drvdata), GFP_KERNEL); + struct ssi_drvdata *new_drvdata; struct device *dev = &plat_dev->dev; struct device_node *np = dev->of_node; u32 signature_val; int rc = 0; - if (unlikely(!new_drvdata)) { + new_drvdata = devm_kzalloc(&plat_dev->dev, sizeof(*new_drvdata), + GFP_KERNEL); + if (!new_drvdata) { SSI_LOG_ERR("Failed to allocate drvdata"); rc = -ENOMEM; goto init_cc_res_err; @@ -434,10 +436,8 @@ static int init_cc_resources(struct platform_device *plat_dev) resource_size(new_drvdata->res_mem)); new_drvdata->res_mem = NULL; } - kfree(new_drvdata); dev_set_drvdata(&plat_dev->dev, NULL); } - return rc; } @@ -478,8 +478,6 @@ static void cleanup_cc_resources(struct platform_device *plat_dev) drvdata->cc_base = NULL; drvdata->res_mem = NULL; } - - kfree(drvdata); dev_set_drvdata(&plat_dev->dev, NULL); } From patchwork Sun Jul 30 16:15:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 108958 Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp2747724obm; Sun, 30 Jul 2017 09:15:52 -0700 (PDT) X-Received: by 10.99.95.76 with SMTP id t73mr13432641pgb.349.1501431352260; Sun, 30 Jul 2017 09:15:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501431352; cv=none; d=google.com; s=arc-20160816; b=o2sO8+kPJ1Z9dRyt/PWcAFG0pmpAot0iLbL16/HfhoJ4Wdy5/SP/nbd1KdSCzyc4NB veCfBF8MUxY/jQaksGOOTjHZOGrZPAUFDj1bLVR4kjEvTODynMnKkvOdidcu5wmNvmeo 9NH+3Ygo9GhFktc2EMB9CW/QHGv88RFjcsLaO3mNIvOgngrjdwRp2hLsb+93babBAxAf /RK2P0C/DKrux2if410CP14ozOTQCh3Ufecj33DJuvbrDK5vgGlWJI51O2l3dpPhtonA KUGun3TBYDYYvLau5FHvr5xLIG2tEaTh52W9XS0N2eDHOU8NASVgc8vzYg2S2hsQjoWN RCTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=owQNQ7qmwbA/GpUNkNyL9ArOK2aM9U1X8TBDcfL/oEc=; b=B+hGUyQtbyLM7NRJR0pHr/Tij2RCZWDLBxOBfozWd8TLHvA/9aslnDnV+SYP0rsjZW P/LwwC/kMR7EWa5IXwJFkOnb3Et3RIfJyf9lxWRXHEy/b8fHUpSIGKAMpwevdeeZ5IoH pKYbpHDB2BBbAHv11tdE4zep13N6VEz7xMgb/Ri5Lp8O38mEb3rSjIzlLHZn+CZGUvBS 1j4oaQnhwFoA1xySjr+hRb6LzZpcsghAR67BTgVvJRlRW/L5ZQxHX/EZIJgJ+yusI8NL 2DamfRw0+IoI3zaHOfoMCjn7kJiOsuEThMGCd4nRKcrzrL03By+EPOLS3cl3J2p6JXfI zXpg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 38si7458132pln.135.2017.07.30.09.15.51; Sun, 30 Jul 2017 09:15:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754288AbdG3QPf (ORCPT + 26 others); Sun, 30 Jul 2017 12:15:35 -0400 Received: from foss.arm.com ([217.140.101.70]:43028 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754248AbdG3QPb (ORCPT ); Sun, 30 Jul 2017 12:15:31 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5AB4E13D5; Sun, 30 Jul 2017 09:15:31 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5E65E3F540; Sun, 30 Jul 2017 09:15:29 -0700 (PDT) From: Gilad Ben-Yossef To: Greg Kroah-Hartman , linux-crypto@vger.kernel.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Cc: Ofir Drang , Suniel Mahesh Subject: [PATCH v2 5/6] staging: ccree: Use platform_get_irq and devm_request_irq Date: Sun, 30 Jul 2017 19:15:07 +0300 Message-Id: <1501431309-27705-6-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1501431309-27705-1-git-send-email-gilad@benyossef.com> References: <1501431309-27705-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suniel Mahesh It is recommended to use managed function devm_request_irq(), which simplifies driver cleanup paths and driver code. This patch does the following: (a) replace platform_get_resource(), request_irq() and corresponding error handling with platform_get_irq() and devm_request_irq(). (b) remove struct resource pointer(res_irq) in struct ssi_drvdata as it seems redundant. (c) change type of member irq in struct ssi_drvdata from unsigned int to int, as return type of platform_get_irq is int and can be used in error handling. (d) remove irq_registered variable from driver probe as it seems redundant. (e) free_irq is not required any more, devm_request_irq() free's it on driver detach. (f) adjust log messages accordingly and remove any blank lines. Signed-off-by: Suniel Mahesh Acked-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_driver.c | 30 +++++++++--------------------- drivers/staging/ccree/ssi_driver.h | 3 +-- 2 files changed, 10 insertions(+), 23 deletions(-) -- 2.1.4 diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index 603eb03..c18e7e3 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -222,7 +222,6 @@ static int init_cc_resources(struct platform_device *plat_dev) { struct resource *req_mem_cc_regs = NULL; void __iomem *cc_base = NULL; - bool irq_registered = false; struct ssi_drvdata *new_drvdata; struct device *dev = &plat_dev->dev; struct device_node *np = dev->of_node; @@ -262,26 +261,22 @@ static int init_cc_resources(struct platform_device *plat_dev) &req_mem_cc_regs->start, new_drvdata->cc_base); cc_base = new_drvdata->cc_base; /* Then IRQ */ - new_drvdata->res_irq = platform_get_resource(plat_dev, IORESOURCE_IRQ, 0); - if (unlikely(!new_drvdata->res_irq)) { + new_drvdata->irq = platform_get_irq(plat_dev, 0); + if (new_drvdata->irq < 0) { SSI_LOG_ERR("Failed getting IRQ resource\n"); - rc = -ENODEV; + rc = new_drvdata->irq; goto init_cc_res_err; } - rc = request_irq(new_drvdata->res_irq->start, cc_isr, - IRQF_SHARED, "arm_cc7x", new_drvdata); - if (unlikely(rc != 0)) { - SSI_LOG_ERR("Could not register to interrupt %llu\n", - (unsigned long long)new_drvdata->res_irq->start); + rc = devm_request_irq(&plat_dev->dev, new_drvdata->irq, cc_isr, + IRQF_SHARED, "arm_cc7x", new_drvdata); + if (rc) { + SSI_LOG_ERR("Could not register to interrupt %d\n", + new_drvdata->irq); goto init_cc_res_err; } init_completion(&new_drvdata->icache_setup_completion); - irq_registered = true; - SSI_LOG_DEBUG("Registered to IRQ (%s) %llu\n", - new_drvdata->res_irq->name, - (unsigned long long)new_drvdata->res_irq->start); - + SSI_LOG_DEBUG("Registered to IRQ: %d\n", new_drvdata->irq); new_drvdata->plat_dev = plat_dev; rc = cc_clk_on(new_drvdata); @@ -410,10 +405,6 @@ static int init_cc_resources(struct platform_device *plat_dev) #ifdef ENABLE_CC_SYSFS ssi_sysfs_fini(); #endif - if (irq_registered) { - free_irq(new_drvdata->res_irq->start, new_drvdata); - new_drvdata->res_irq = NULL; - } dev_set_drvdata(&plat_dev->dev, NULL); } return rc; @@ -443,11 +434,8 @@ static void cleanup_cc_resources(struct platform_device *plat_dev) #ifdef ENABLE_CC_SYSFS ssi_sysfs_fini(); #endif - fini_cc_regs(drvdata); cc_clk_off(drvdata); - free_irq(drvdata->res_irq->start, drvdata); - drvdata->res_irq = NULL; dev_set_drvdata(&plat_dev->dev, NULL); } diff --git a/drivers/staging/ccree/ssi_driver.h b/drivers/staging/ccree/ssi_driver.h index 518c0bf..88ef370 100644 --- a/drivers/staging/ccree/ssi_driver.h +++ b/drivers/staging/ccree/ssi_driver.h @@ -128,9 +128,8 @@ struct ssi_crypto_req { * @fw_ver: SeP loaded firmware version */ struct ssi_drvdata { - struct resource *res_irq; void __iomem *cc_base; - unsigned int irq; + int irq; u32 irq_mask; u32 fw_ver; /* Calibration time of start/stop From patchwork Sun Jul 30 16:15:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 108959 Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp2747792obm; Sun, 30 Jul 2017 09:15:58 -0700 (PDT) X-Received: by 10.101.85.132 with SMTP id j4mr13511131pgs.68.1501431357965; Sun, 30 Jul 2017 09:15:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501431357; cv=none; d=google.com; s=arc-20160816; b=vb+0Pr20BnH60HMB+1xnJO/Q+2Pu4k90oz3D1nJr4hx7AOxGbBJ5PqwqB5bSvpvQA/ OeHPIgrlJedzkDRAzF/8dAmhWtxo5wgKmXClnFZaZQJjoevZKehFWza2p6fsmGS8KvBX 5oUPO79LIGHTEDly2XX1W2eWMa+6cLwe+Smd0EENliCA7d/HCI/6BqY79dlkLMpczhSy NFaVTwQqiFDpBYOGJWu4jHwnZ0YdD5hBAUF3KwnlLi5PP5cvMPEDOq1rh+dKNtRwbIBD hi8ZQdoIZ5H0SAsYrHPorla8NNkii+qVPqooFGi1AQOLK1COcdsx3B2CSX2xhJKcFYT4 KRaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=ViBAtnrn8zH8a57llzMORLRKTorb01Q0h+gxhm3Ow7Q=; b=R7HIcFBll0FNDulyJY9904JNOtWtORv7b3AzIbYcszpOYLp/WiEnn8ibbSD34w4SOT Vi8CFAFuDnt8FWEJ40JygPu0SQAysjAuVAYa5mySi9kPQO+Y0F53I31iFLqqQTNRSbas lb42fR2Hi4cD9909IQUJSyuElFNywAXnsrCfEbt4x64aLb0XlbrfWBiih1krxcMIAbTl 0IuJlIkJyFuC3+xlrZ9NsKcF7OAfoarkbuQMVNGnwxJTPvG5bZJZ1w6PrC0+uAMDQI3y druk/2c6L94MKer9ms2gMkdtmdeFunPY974jho645fZdGnmgKTtXOfbDQ2cbRkA/13O3 dW/g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 38si7458132pln.135.2017.07.30.09.15.57; Sun, 30 Jul 2017 09:15:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754334AbdG3QPx (ORCPT + 26 others); Sun, 30 Jul 2017 12:15:53 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:43036 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754277AbdG3QPf (ORCPT ); Sun, 30 Jul 2017 12:15:35 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A719F13D5; Sun, 30 Jul 2017 09:15:34 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DCE9C3F540; Sun, 30 Jul 2017 09:15:32 -0700 (PDT) From: Gilad Ben-Yossef To: Greg Kroah-Hartman , linux-crypto@vger.kernel.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v2 6/6] staging: ccree: simplify resource release on error Date: Sun, 30 Jul 2017 19:15:08 +0300 Message-Id: <1501431309-27705-7-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1501431309-27705-1-git-send-email-gilad@benyossef.com> References: <1501431309-27705-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The resource release on probe/init error was being handled in an awkward manner and possibly leaking memory on certain (unlikely) error path. Fix it by simplifying the error resource release and making it easier to track. Reported-by: Dan Carpenter Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_aead.c | 3 +- drivers/staging/ccree/ssi_cipher.c | 3 +- drivers/staging/ccree/ssi_driver.c | 102 ++++++++++++++++++++----------------- drivers/staging/ccree/ssi_hash.c | 3 +- 4 files changed, 59 insertions(+), 52 deletions(-) -- 2.1.4 diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c index a8cb432..66eedbe 100644 --- a/drivers/staging/ccree/ssi_aead.c +++ b/drivers/staging/ccree/ssi_aead.c @@ -2719,6 +2719,7 @@ int ssi_aead_alloc(struct ssi_drvdata *drvdata) goto fail0; } + INIT_LIST_HEAD(&aead_handle->aead_list); drvdata->aead_handle = aead_handle; aead_handle->sram_workspace_addr = ssi_sram_mgr_alloc( @@ -2729,8 +2730,6 @@ int ssi_aead_alloc(struct ssi_drvdata *drvdata) goto fail1; } - INIT_LIST_HEAD(&aead_handle->aead_list); - /* Linux crypto */ for (alg = 0; alg < ARRAY_SIZE(aead_algs); alg++) { t_alg = ssi_aead_create_alg(&aead_algs[alg]); diff --git a/drivers/staging/ccree/ssi_cipher.c b/drivers/staging/ccree/ssi_cipher.c index d98178d..712b21d 100644 --- a/drivers/staging/ccree/ssi_cipher.c +++ b/drivers/staging/ccree/ssi_cipher.c @@ -1281,9 +1281,8 @@ int ssi_ablkcipher_alloc(struct ssi_drvdata *drvdata) if (!ablkcipher_handle) return -ENOMEM; - drvdata->blkcipher_handle = ablkcipher_handle; - INIT_LIST_HEAD(&ablkcipher_handle->blkcipher_alg_list); + drvdata->blkcipher_handle = ablkcipher_handle; /* Linux crypto */ SSI_LOG_DEBUG("Number of algorithms = %zu\n", ARRAY_SIZE(blkcipher_algs)); diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index c18e7e3..1b95f90 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -233,16 +233,14 @@ static int init_cc_resources(struct platform_device *plat_dev) if (!new_drvdata) { SSI_LOG_ERR("Failed to allocate drvdata"); rc = -ENOMEM; - goto init_cc_res_err; + goto post_drvdata_err; } + dev_set_drvdata(&plat_dev->dev, new_drvdata); + new_drvdata->plat_dev = plat_dev; new_drvdata->clk = of_clk_get(np, 0); new_drvdata->coherent = of_dma_is_coherent(np); - /*Initialize inflight counter used in dx_ablkcipher_secure_complete used for count of BYSPASS blocks operations*/ - new_drvdata->inflight_counter = 0; - - dev_set_drvdata(&plat_dev->dev, new_drvdata); /* Get device resources */ /* First CC registers space */ req_mem_cc_regs = platform_get_resource(plat_dev, IORESOURCE_MEM, 0); @@ -250,38 +248,42 @@ static int init_cc_resources(struct platform_device *plat_dev) new_drvdata->cc_base = devm_ioremap_resource(&plat_dev->dev, req_mem_cc_regs); if (IS_ERR(new_drvdata->cc_base)) { + SSI_LOG_ERR("Failed to ioremap registers"); rc = PTR_ERR(new_drvdata->cc_base); - goto init_cc_res_err; + goto post_drvdata_err; } + SSI_LOG_DEBUG("Got MEM resource (%s): start=%pad end=%pad\n", req_mem_cc_regs->name, req_mem_cc_regs->start, req_mem_cc_regs->end); SSI_LOG_DEBUG("CC registers mapped from %pa to 0x%p\n", &req_mem_cc_regs->start, new_drvdata->cc_base); + cc_base = new_drvdata->cc_base; + /* Then IRQ */ new_drvdata->irq = platform_get_irq(plat_dev, 0); if (new_drvdata->irq < 0) { SSI_LOG_ERR("Failed getting IRQ resource\n"); rc = new_drvdata->irq; - goto init_cc_res_err; + goto post_drvdata_err; } + rc = devm_request_irq(&plat_dev->dev, new_drvdata->irq, cc_isr, IRQF_SHARED, "arm_cc7x", new_drvdata); if (rc) { SSI_LOG_ERR("Could not register to interrupt %d\n", new_drvdata->irq); - goto init_cc_res_err; + goto post_drvdata_err; } - init_completion(&new_drvdata->icache_setup_completion); - SSI_LOG_DEBUG("Registered to IRQ: %d\n", new_drvdata->irq); - new_drvdata->plat_dev = plat_dev; + + init_completion(&new_drvdata->icache_setup_completion); rc = cc_clk_on(new_drvdata); if (rc) - goto init_cc_res_err; + goto post_drvdata_err; if (!new_drvdata->plat_dev->dev.dma_mask) new_drvdata->plat_dev->dev.dma_mask = &new_drvdata->plat_dev->dev.coherent_dma_mask; @@ -295,7 +297,7 @@ static int init_cc_resources(struct platform_device *plat_dev) SSI_LOG_ERR("Invalid CC signature: SIGNATURE=0x%08X != expected=0x%08X\n", signature_val, (u32)DX_DEV_SIGNATURE); rc = -EINVAL; - goto init_cc_res_err; + goto post_clk_err; } SSI_LOG_DEBUG("CC SIGNATURE=0x%08X\n", signature_val); @@ -306,21 +308,26 @@ static int init_cc_resources(struct platform_device *plat_dev) rc = init_cc_regs(new_drvdata, true); if (unlikely(rc != 0)) { SSI_LOG_ERR("init_cc_regs failed\n"); - goto init_cc_res_err; + goto post_clk_err; } #ifdef ENABLE_CC_SYSFS rc = ssi_sysfs_init(&plat_dev->dev.kobj, new_drvdata); if (unlikely(rc != 0)) { SSI_LOG_ERR("init_stat_db failed\n"); - goto init_cc_res_err; + goto post_regs_err; } #endif + rc = ssi_fips_init(new_drvdata); + if (unlikely(rc != 0)) { + SSI_LOG_ERR("SSI_FIPS_INIT failed 0x%x\n", rc); + goto post_sysfs_err; + } rc = ssi_sram_mgr_init(new_drvdata); if (unlikely(rc != 0)) { SSI_LOG_ERR("ssi_sram_mgr_init failed\n"); - goto init_cc_res_err; + goto post_fips_init_err; } new_drvdata->mlli_sram_addr = @@ -328,57 +335,51 @@ static int init_cc_resources(struct platform_device *plat_dev) if (unlikely(new_drvdata->mlli_sram_addr == NULL_SRAM_ADDR)) { SSI_LOG_ERR("Failed to alloc MLLI Sram buffer\n"); rc = -ENOMEM; - goto init_cc_res_err; + goto post_sram_mgr_err; } rc = request_mgr_init(new_drvdata); if (unlikely(rc != 0)) { SSI_LOG_ERR("request_mgr_init failed\n"); - goto init_cc_res_err; + goto post_sram_mgr_err; } rc = ssi_buffer_mgr_init(new_drvdata); if (unlikely(rc != 0)) { SSI_LOG_ERR("buffer_mgr_init failed\n"); - goto init_cc_res_err; + goto post_req_mgr_err; } rc = ssi_power_mgr_init(new_drvdata); if (unlikely(rc != 0)) { SSI_LOG_ERR("ssi_power_mgr_init failed\n"); - goto init_cc_res_err; - } - - rc = ssi_fips_init(new_drvdata); - if (unlikely(rc != 0)) { - SSI_LOG_ERR("SSI_FIPS_INIT failed 0x%x\n", rc); - goto init_cc_res_err; + goto post_buf_mgr_err; } rc = ssi_ivgen_init(new_drvdata); if (unlikely(rc != 0)) { SSI_LOG_ERR("ssi_ivgen_init failed\n"); - goto init_cc_res_err; + goto post_power_mgr_err; } /* Allocate crypto algs */ rc = ssi_ablkcipher_alloc(new_drvdata); if (unlikely(rc != 0)) { SSI_LOG_ERR("ssi_ablkcipher_alloc failed\n"); - goto init_cc_res_err; + goto post_ivgen_err; } /* hash must be allocated before aead since hash exports APIs */ rc = ssi_hash_alloc(new_drvdata); if (unlikely(rc != 0)) { SSI_LOG_ERR("ssi_hash_alloc failed\n"); - goto init_cc_res_err; + goto post_cipher_err; } rc = ssi_aead_alloc(new_drvdata); if (unlikely(rc != 0)) { SSI_LOG_ERR("ssi_aead_alloc failed\n"); - goto init_cc_res_err; + goto post_hash_err; } /* If we got here and FIPS mode is enabled @@ -389,24 +390,33 @@ static int init_cc_resources(struct platform_device *plat_dev) return 0; -init_cc_res_err: - SSI_LOG_ERR("Freeing CC HW resources!\n"); - - if (new_drvdata) { - ssi_aead_free(new_drvdata); - ssi_hash_free(new_drvdata); - ssi_ablkcipher_free(new_drvdata); - ssi_ivgen_fini(new_drvdata); - ssi_power_mgr_fini(new_drvdata); - ssi_buffer_mgr_fini(new_drvdata); - request_mgr_fini(new_drvdata); - ssi_sram_mgr_fini(new_drvdata); - ssi_fips_fini(new_drvdata); +post_hash_err: + ssi_hash_free(new_drvdata); +post_cipher_err: + ssi_ablkcipher_free(new_drvdata); +post_ivgen_err: + ssi_ivgen_fini(new_drvdata); +post_power_mgr_err: + ssi_power_mgr_fini(new_drvdata); +post_buf_mgr_err: + ssi_buffer_mgr_fini(new_drvdata); +post_req_mgr_err: + request_mgr_fini(new_drvdata); +post_sram_mgr_err: + ssi_sram_mgr_fini(new_drvdata); +post_fips_init_err: + ssi_fips_fini(new_drvdata); +post_sysfs_err: #ifdef ENABLE_CC_SYSFS - ssi_sysfs_fini(); + ssi_sysfs_fini(); #endif - dev_set_drvdata(&plat_dev->dev, NULL); - } +post_regs_err: + fini_cc_regs(new_drvdata); +post_clk_err: + cc_clk_off(new_drvdata); +post_drvdata_err: + SSI_LOG_ERR("ccree init error occurred!\n"); + dev_set_drvdata(&plat_dev->dev, NULL); return rc; } diff --git a/drivers/staging/ccree/ssi_hash.c b/drivers/staging/ccree/ssi_hash.c index 6c08b1d..3e7873c 100644 --- a/drivers/staging/ccree/ssi_hash.c +++ b/drivers/staging/ccree/ssi_hash.c @@ -2229,6 +2229,7 @@ int ssi_hash_alloc(struct ssi_drvdata *drvdata) goto fail; } + INIT_LIST_HEAD(&hash_handle->hash_list); drvdata->hash_handle = hash_handle; sram_size_to_alloc = sizeof(digest_len_init) + @@ -2259,8 +2260,6 @@ int ssi_hash_alloc(struct ssi_drvdata *drvdata) goto fail; } - INIT_LIST_HEAD(&hash_handle->hash_list); - /* ahash registration */ for (alg = 0; alg < ARRAY_SIZE(driver_hash); alg++) { struct ssi_hash_alg *t_alg;