2015-11-19 12:39:30

by Corentin Labbe

[permalink] [raw]
Subject: [PATCH 1/2] crypto: sahara: set nb_[in|out]_sg as signed int

The two unsigned int variables nb_in_sg and nb_out_sg can be assigned
signed value (-EINVAL) from sg_nents_for_len().
Furthermore they are used only by dma_map_sg and dma_unmap_sg which wait
for an signed int, so they must be set as int.

Fixes: 6c2b74d4774f ("crypto: sahara - check return value of sg_nents_for_len")
Reported-by: Dan Carpenter <[email protected]>
Signed-off-by: LABBE Corentin <[email protected]>
---
drivers/crypto/sahara.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/sahara.c b/drivers/crypto/sahara.c
index ea9f56a..cc738f3 100644
--- a/drivers/crypto/sahara.c
+++ b/drivers/crypto/sahara.c
@@ -228,9 +228,9 @@ struct sahara_dev {

size_t total;
struct scatterlist *in_sg;
- unsigned int nb_in_sg;
+ int nb_in_sg;
struct scatterlist *out_sg;
- unsigned int nb_out_sg;
+ int nb_out_sg;

u32 error;
};
--
2.4.10


2015-11-19 12:39:34

by Corentin Labbe

[permalink] [raw]
Subject: [PATCH 2/2] crypto: picoxcell: set [src|dst]_nents and nents as signed int

The unsigned int variables [src|dst]_nents and nents can be assigned
signed value (-EINVAL) from sg_nents_for_len().
Furthermore they are used only by dma_map_sg and dma_unmap_sg which wait
for an signed int, so they must be set as int.

Fixes: f051f95eb47b ("crypto: picoxcell - check return value of sg_nents_for_len")
Reported-by: Dan Carpenter <[email protected]>
Signed-off-by: LABBE Corentin <[email protected]>
---
drivers/crypto/picoxcell_crypto.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/picoxcell_crypto.c b/drivers/crypto/picoxcell_crypto.c
index a9c6367..15b5e39 100644
--- a/drivers/crypto/picoxcell_crypto.c
+++ b/drivers/crypto/picoxcell_crypto.c
@@ -289,10 +289,11 @@ static struct spacc_ddt *spacc_sg_to_ddt(struct spacc_engine *engine,
enum dma_data_direction dir,
dma_addr_t *ddt_phys)
{
- unsigned nents, mapped_ents;
+ unsigned mapped_ents;
struct scatterlist *cur;
struct spacc_ddt *ddt;
int i;
+ int nents;

nents = sg_nents_for_len(payload, nbytes);
if (nents < 0) {
@@ -326,7 +327,7 @@ static int spacc_aead_make_ddts(struct aead_request *areq)
struct spacc_engine *engine = req->engine;
struct spacc_ddt *src_ddt, *dst_ddt;
unsigned total;
- unsigned int src_nents, dst_nents;
+ int src_nents, dst_nents;
struct scatterlist *cur;
int i, dst_ents, src_ents;

--
2.4.10

2015-11-23 13:05:51

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH 1/2] crypto: sahara: set nb_[in|out]_sg as signed int

On Thu, Nov 19, 2015 at 01:38:17PM +0100, LABBE Corentin wrote:
> The two unsigned int variables nb_in_sg and nb_out_sg can be assigned
> signed value (-EINVAL) from sg_nents_for_len().
> Furthermore they are used only by dma_map_sg and dma_unmap_sg which wait
> for an signed int, so they must be set as int.
>
> Fixes: 6c2b74d4774f ("crypto: sahara - check return value of sg_nents_for_len")
> Reported-by: Dan Carpenter <[email protected]>
> Signed-off-by: LABBE Corentin <[email protected]>

Both patches applied. Thanks.
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt