Skip to content

Commit

Permalink
crypto: caam - fix descriptor length adjustments for protocol descrip…
Browse files Browse the repository at this point in the history
…tors

init_desc, by always ORing with 1 for the descriptor header inclusion
into the descriptor length, and init_sh_desc_pdb, by always specifying
the descriptor length modification for the PDB via options, would not
allow for odd length PDBs to be embedded in the constructed descriptor
length.  Fix this by simply changing the OR to an addition.

also round-up pdb_bytes to the next SEC command unit size, to
allow for, e.g., optional packet header bytes that aren't a
multiple of CAAM_CMD_SZ.

Reported-by: Radu-Andrei BULIE <radu.bulie@freescale.com>
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
Cc: Yashpal Dutta <yashpal.dutta@freescale.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
Kim Phillips authored and Herbert Xu committed Jun 27, 2012
1 parent c4b6640 commit 991c569
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/crypto/caam/desc_constr.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static inline void *sh_desc_pdb(u32 *desc)

static inline void init_desc(u32 *desc, u32 options)
{
*desc = options | HDR_ONE | 1;
*desc = (options | HDR_ONE) + 1;
}

static inline void init_sh_desc(u32 *desc, u32 options)
Expand All @@ -62,7 +62,7 @@ static inline void init_sh_desc(u32 *desc, u32 options)

static inline void init_sh_desc_pdb(u32 *desc, u32 options, size_t pdb_bytes)
{
u32 pdb_len = pdb_bytes / CAAM_CMD_SZ + 1;
u32 pdb_len = (pdb_bytes + CAAM_CMD_SZ - 1) / CAAM_CMD_SZ;

init_sh_desc(desc, (((pdb_len + 1) << HDR_START_IDX_SHIFT) + pdb_len) |
options);
Expand Down

0 comments on commit 991c569

Please sign in to comment.