Commit Graph

188 Commits

Author SHA1 Message Date
Dan Carpenter aece090244 staging: ccree: Uninitialized return in ssi_ahash_import()
The return value isn't initialized on some success paths.

Fixes: c5f39d0786 ("staging: ccree: fix leak of import() after init()")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-06 15:49:26 +01:00
Gilad Ben-Yossef c5f39d0786 staging: ccree: fix leak of import() after init()
crypto_ahash_import() may be called either after
crypto_ahash_init() or without such call. Right now
we always internally call init() as part of
import(), thus leaking memory and mappings if the
user has already called init() herself.

Fix this by only calling init() internally if the
state is not already initialized.

Fixes: commit 454527d0d9 ("staging: ccree: fix hash import/export")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-28 14:36:45 +01:00
Gilad Ben-Yossef 7f5ce9dddb staging: ccree: simplify ioread/iowrite
Registers ioread/iowrite operations were done via macros,
sometime using a "magical" implicit parameter.

Replace all register access with simple inline macros.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-06 16:47:04 +01:00
Gilad Ben-Yossef 57a1f2a04a staging: ccree: simplify registers access
The register offset calculation macro was taking a HW block base
parameter that was not actually used. Simplify the whole thing
by dropping it and rename the macro for better readability.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-06 16:47:04 +01:00
Gilad Ben-Yossef e979f35675 staging: ccree: simplify error handling logic
Turn the code sites that don't require any special handling
on error return to a simple return.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-06 16:47:04 +01:00
Gilad Ben-Yossef 642ed0c32b staging: ccree: remove dead code
The inflight_counter field is updated in a single location and
never used. Remove it.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-06 16:46:03 +01:00
Gilad Ben-Yossef 414a48e88d staging: ccree: handle limiting of DMA masks
Properly handle limiting of DMA masks based on device and bus
capabilities.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-06 16:46:03 +01:00
Gilad Ben-Yossef e7cdcba451 staging: ccree: copy IV to DMAable memory
We are being passed an IV buffer from unknown origin, which may be
stack allocated and thus not safe for DMA. Allocate a DMA safe
buffer for the IV and use that instead.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-06 16:46:03 +01:00
Stephen Brennan 1dc2f73a17 staging: ccree: Fix indentation in ssi_buffer_mgr.c
In particular, fixes some over-indented if statement bodies as well as a
couple lines indented with spaces. checkpatch.pl now reports no warnings
on this file other than 80 character warnings.

Signed-off-by: Stephen Brennan <stephen@brennan.io>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-02 11:39:44 +01:00
Gilad Ben-Yossef e0b3f39092 staging: ccree: fix 64 bit scatter/gather DMA ops
Fix a wrong offset used in splitting a 64 DMA address to MSB/LSB
parts needed for scatter/gather HW descriptors causing operations
relying on them to fail on 64 bit platforms.

Fixes: c6f7f2f459 ("staging: ccree: refactor LLI access macros")
Reported-by: Stuart Yoder <stuart.yoder@arm.com>
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-02 11:39:44 +01:00
Suniel Mahesh 78cd0ddc67 staging: ccree: fix boolreturn.cocci warning
This fixes the following coccinelle warning:
WARNING: return of 0/1 in function 'ssi_is_hw_key' with return type bool.

return "false" instead of 0.

Signed-off-by: Suniel Mahesh <sunil.m@techveda.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-18 15:33:15 +02:00
Suniel Mahesh 8fc9772543 staging: ccree: Fix bool comparison
Comparision operator "equal to" not required on a variable
"foo" of type "bool". Bool has only two values, can be used
directly or with logical not.

This fixes the following coccinelle warning:
WARNING: Comparison of bool to 0/1

Signed-off-by: Suniel Mahesh <sunil.m@techveda.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-18 15:33:15 +02:00
Rishabh Hardas 37ba0e399c staging/ccree: Declare compiled out functions static inline
Sparse was giving out a warning for symbols
'cc_set_ree_fips_status' and 'fips_handler'
that they were not declared and need to be
made static. This patch makes both the symbols
static inline, to remove the warnings.

Signed-off-by: Rishabh Hardas <rishabhhardas@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-18 15:33:15 +02:00
Suniel Mahesh 006e202fe6 staging: ccree: Convert to platform_{get,set}_drvdata()
Platform devices are expected to use wrapper functions,
platform_{get,set}_drvdata() with platform_device as argument,
for getting and setting the driver data. dev_{get,set}_drvdata()
are using &plat_dev->dev.
For wrapper functions we can directly pass a struct platform_device.

dev_set_drvdata() is redundant and therefore removed. The driver core
clears the driver data to NULL after device_release or on probe failure.

Signed-off-by: Suniel Mahesh <sunil.m@techveda.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-04 10:26:34 +02:00
Suniel Mahesh abd4b78793 staging: ccree: else is not generally useful after a break or return
Fixes checkpatch warnings:

WARNING: else is not generally useful after a break or return

Signed-off-by: Suniel Mahesh <sunil.m@techveda.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-03 18:29:07 +02:00
Gilad Ben-Yossef 553aff5f1b staging: ccree: simplify OOM handling
Simplify handling of memory allocation failures and remove
redundant log messages

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-03 18:28:17 +02:00
Gilad Ben-Yossef bdd0873dc2 staging: ccree: move to generic device log infra
Move over from using macro wrappers around to printk to
dev_err, dev_dbg and friends and clean up resulting fallout.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-03 18:28:17 +02:00
Gilad Ben-Yossef a55ef6f52f staging: ccree: simplify access to struct device
Introduce a function to retrieve struct device from private
data structure in preparation to replacing custom logging
macros with proper dev_dbg and friends which require struct
device.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-03 18:28:17 +02:00
Gilad Ben-Yossef 613fa6f1d3 staging: ccree: remove sysfs if of deleted code
The ccree cycle count mechanism was removed in
commit 7f821f0c6f ("staging: ccree: remove cycle count debug support")
but the sysfs interface lingered on. Remove it now.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-03 18:28:17 +02:00
Colin Ian King c5bf891402 staging: ccree: remove unused and redundant variable idx
Variable idx is being set but never read and thus it can be
removed because it is redundant. Cleans up clang build warnings:

warning: Value stored to 'idx' during its initialization is never read
warning: Value stored to 'idx' is never read
warning: Value stored to 'idx' is never read

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-09-18 12:23:40 +02:00
Srishti Sharma aabdabad35 Staging: ccree: Use kcalloc instead of kzalloc
Use kcalloc instead of kzalloc to check for overflow before
multiplication. Done using the following semantic patch by
coccinelle.

http://coccinelle.lip6.fr/rules/kzalloc.cocci

Signed-off-by: Srishti Sharma <srishtishar@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-09-18 12:00:07 +02:00
Srishti Sharma 2af630f0d3 Staging: ccree: Remove unused variable monitor_lock
Remove the variable monitor_lock as it is not used anywhere.

Signed-off-by: Srishti Sharma <srishtishar@gmail.com>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Acked-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-09-17 16:35:27 +02:00
Srishti Sharma 63fcb0ce01 Staging: ccree: Merge assignment with return
Merge the assignment and the return statements to return the value
directly. Done using coccinelle.

@@
local idexpression ret;
expression e;
@@

-ret =
+return
     e;
-return ret;

Signed-off-by: Srishti Sharma <srishtishar@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-09-17 16:35:26 +02:00
Gilad Ben-Yossef 9ba7bdc9d9 staging: ccree: remove BUG macro usage
Replace BUG() macro usage that crash the kernel with alternatives
that signal error and/or try to recover.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-09-17 16:35:26 +02:00
Gilad Ben-Yossef 3b2eb3799e staging: ccree: replace noop macro with inline
Replace noop macro with a noop inline function

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-09-17 16:35:26 +02:00
Gilad Ben-Yossef f11c619c57 staging: ccree: move over to BIT macro for bit defines
Use BIT macro for bit definitions where needed.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-09-17 16:35:26 +02:00
Gilad Ben-Yossef 707c76a0e9 staging: ccree: remove unused completion
icache_setup_completion is no longer used. Remove it.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-09-17 16:35:26 +02:00
Gilad Ben-Yossef 093d561565 staging: ccree: simplify resource release on error
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 <dan.carpenter@oracle.com>
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-09-17 16:35:25 +02:00
Suniel Mahesh 7f6f832d25 staging: ccree: Use platform_get_irq and devm_request_irq
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 <sunil.m@techveda.org>
Acked-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-09-17 16:35:25 +02:00
Suniel Mahesh ce58df6394 staging: ccree: Convert to devm_ioremap_resource for map, unmap
It is recommended to use managed function devm_ioremap_resource(),
which simplifies driver cleanup paths and driver code.
This patch does the following:
(a) replace request_mem_region(), ioremap() and corresponding error
handling with devm_ioremap_resource().
(b) remove struct resource pointer(res_mem) in struct ssi_drvdata as it
seems redundant, use struct resource pointer which is defined locally and
adjust return value of platform_get_resource() accordingly.
(c) release_mem_region() and iounmap() are dropped, since devm_ioremap_
resource() releases and unmaps mem region on driver detach.
(d) adjust log messages accordingly and remove any blank lines.

Signed-off-by: Suniel Mahesh <sunil.m@techveda.org>
[gby: rebase on top of latest coding style fixes changes]
Acked-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-09-17 16:35:25 +02:00
Suniel Mahesh 92c9f47202 staging: ccree: Replace kzalloc with devm_kzalloc
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 <sunil.m@techveda.org>
[gby: rebase on top of latest coding style fixes changes]
Acked-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-09-17 16:35:25 +02:00
Srishti Sharma 17d46dace2 Staging: ccree: Remove unused variable.
Remove the local variable inflight_counter as it is never used.

Signed-off-by: Srishti Sharma <srishtishar@gmail.com>
Acked-by: Gilad Ben-Yossef <gilad@benyossef.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-09-17 16:35:25 +02:00
Gilad Ben-Yossef 737aed947f staging: ccree: save ciphertext for CTS IV
The crypto API requires saving the last blocks of ciphertext
in req->info for use as IV for CTS mode. The ccree driver
was not doing this. This patch fixes that.

The bug was manifested with cts(cbc(aes)) mode in tcrypt tests.

Fixes: 302ef8ebb4 ("Add CryptoCell skcipher support")
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-08-23 16:22:35 -07:00
Arvind Yadav 22d82cb952 staging: ccree: constify dev_pm_ops structures.
dev_pm_ops are not supposed to change at runtime. All functions
working with dev_pm_ops provided by <linux/device.h> work with const
dev_pm_ops. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-08-16 15:10:42 -07:00
Simon Sandström 8bf4851291 staging: ccree: Use sizeof(variable) in memory allocs
Fixes 9 checkpatch.pl warnings of type
"Prefer kmalloc(sizeof(variable)...) over kmalloc(sizeof(type)...)"
in staging/ccree.

Signed-off-by: Simon Sandström <simon@nikanor.nu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-08-16 15:10:42 -07:00
Suniel Mahesh a7b1ba2355 staging: ccree: Fix unnecessary NULL check before kfree'ing it
kfree(NULL) is safe and their is no need for a NULL check. Pointed out
by checkpatch.

Signed-off-by: Suniel Mahesh <sunil.m@techveda.org>
Acked-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-27 21:55:24 -07:00
Gilad Ben-Yossef 4a457c1710 staging: ccree: remove func name from log messages
The SSI_LOG macros already add __func__ to log messages, so remove
log message that add them a second time in the log message itself.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-27 21:54:06 -07:00
Simon Sandström 28471424d1 staging: ccree: Fix alignment issues in ssi_request_mgr.c
Fixes checkpatch.pl alignment warnings.

Signed-off-by: Simon Sandström <simon@nikanor.nu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-27 21:53:22 -07:00
Simon Sandström e7ced775dc staging: ccree: Fix alignment issues in ssi_ivgen.c
Fixes checkpatch.pl alignment warnings.

Signed-off-by: Simon Sandström <simon@nikanor.nu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-27 21:53:22 -07:00
Simon Sandström 32fabb034f staging: ccree: Fix alignment issues in ssi_cipher.c
Fixes checkpatch.pl alignment warnings.

Signed-off-by: Simon Sandström <simon@nikanor.nu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-27 21:53:21 -07:00
Simon Sandström 4ff66c46b0 staging: ccree: Fix alignment issues in ssi_buffer_mgr.c
Fixes checkpatch.pl alignment warnings.

Signed-off-by: Simon Sandström <simon@nikanor.nu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-27 21:53:21 -07:00
Simon Sandström 3151c1df14 staging: ccree: Fix alignment issues in ssi_hash.c
Fixes checkpatch.pl alignment warnings.

Signed-off-by: Simon Sandström <simon@nikanor.nu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-27 21:53:21 -07:00
Simon Sandström bb1b78c3f0 staging: ccree: Fix alignment issues in ssi_aead.c
Fixes checkpatch.pl alignment warnings.

Signed-off-by: Simon Sandström <simon@nikanor.nu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-27 21:53:21 -07:00
Dhananjay Balan 5311678279 drivers: staging: ccree: use __func__ to get function name in error messages.
fixes checkpatch warning.

Signed-off-by: Dhananjay Balan <mail@dbalan.in>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-18 08:57:59 +02:00
Bincy K Philip 187645ef1f staging: ccree: move comment to fit coding style
Trivial fix for Line over 80 characters

Moved the comment to top of the definition

Signed-off-by: Bincy K Philip <bincy_k_philip@yahoo.co.in>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-16 08:41:02 +02:00
Gilad Ben-Yossef 04f682b936 staging: ccree: remove whitespace before a quoted newline
Remove unnecessary whitespace before a quoted newline in strings.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-16 08:41:02 +02:00
Gilad Ben-Yossef b71ad22dff staging: ccree: avoid unnecessary line continuation
Avoid unnecessary line continuation in log function call.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-16 08:41:01 +02:00
Gilad Ben-Yossef 079a7174ae staging: ccree: avoid constant comparison
Re-write predicate to avoid constant comparison.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-16 08:41:01 +02:00
Gilad Ben-Yossef 698592e23e staging: ccree: CamelCase to snake_case in aead struct
Rename aead_req_struct fields from CamelCase to snake_case.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-16 08:41:01 +02:00
Gilad Ben-Yossef 42886fab0d staging: ccree: CamelCase to snake_case in func vars
Turn local vars and function parameters names in CamelCase
to snake_case.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-16 08:41:01 +02:00