Message ID | 20180609182235.33532-7-sjg@chromium.org |
---|---|
State | Superseded |
Delegated to: | Tom Rini |
Headers | show |
Series | Fix some coverity warnings | expand |
On 06/09/2018 08:22 PM, Simon Glass wrote: > Thsi function can fail without freeing all its memory. Fix it. > > Reported-by: Coverity (CID: 131217) > Signed-off-by: Simon Glass <sjg@chromium.org> > --- > > lib/rsa/rsa-sign.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/lib/rsa/rsa-sign.c b/lib/rsa/rsa-sign.c > index d2788bf79a..2a09d2b19e 100644 > --- a/lib/rsa/rsa-sign.c > +++ b/lib/rsa/rsa-sign.c > @@ -667,15 +667,13 @@ static int fdt_add_bignum(void *blob, int noffset, const char *prop_name, > * might fail several times Please, fix the memory leaks above this line too. Best regards Heinrich > */ > ret = fdt_setprop(blob, noffset, prop_name, buf, size); > - if (ret) > - return -FDT_ERR_NOSPACE; > free(buf); > BN_free(tmp); > BN_free(big2); > BN_free(big32); > BN_free(big2_32); > > - return ret; > + return ret ? -FDT_ERR_NOSPACE : 0; > } > > int rsa_add_verify_data(struct image_sign_info *info, void *keydest) >
Hi Heinrich, On 9 June 2018 at 13:50, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote: > On 06/09/2018 08:22 PM, Simon Glass wrote: >> Thsi function can fail without freeing all its memory. Fix it. >> >> Reported-by: Coverity (CID: 131217) >> Signed-off-by: Simon Glass <sjg@chromium.org> >> --- >> >> lib/rsa/rsa-sign.c | 4 +--- >> 1 file changed, 1 insertion(+), 3 deletions(-) >> >> diff --git a/lib/rsa/rsa-sign.c b/lib/rsa/rsa-sign.c >> index d2788bf79a..2a09d2b19e 100644 >> --- a/lib/rsa/rsa-sign.c >> +++ b/lib/rsa/rsa-sign.c >> @@ -667,15 +667,13 @@ static int fdt_add_bignum(void *blob, int noffset, const char *prop_name, >> * might fail several times > > Please, fix the memory leaks above this line too. Coverity does not seem to detect these as memory leaks. I've added a comment explaining why I don't think it makes sense to 'fix' these. Regards, Simon
diff --git a/lib/rsa/rsa-sign.c b/lib/rsa/rsa-sign.c index d2788bf79a..2a09d2b19e 100644 --- a/lib/rsa/rsa-sign.c +++ b/lib/rsa/rsa-sign.c @@ -667,15 +667,13 @@ static int fdt_add_bignum(void *blob, int noffset, const char *prop_name, * might fail several times */ ret = fdt_setprop(blob, noffset, prop_name, buf, size); - if (ret) - return -FDT_ERR_NOSPACE; free(buf); BN_free(tmp); BN_free(big2); BN_free(big32); BN_free(big2_32); - return ret; + return ret ? -FDT_ERR_NOSPACE : 0; } int rsa_add_verify_data(struct image_sign_info *info, void *keydest)
Thsi function can fail without freeing all its memory. Fix it. Reported-by: Coverity (CID: 131217) Signed-off-by: Simon Glass <sjg@chromium.org> --- lib/rsa/rsa-sign.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)