mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Sam Ravnborg <sam@ravnborg.org>
Cc: barebox@lists.infradead.org, kernel@pengutronix.de
Subject: Re: [PATCH 1/3] crypto: add enum
Date: Wed, 6 Jan 2016 15:39:47 +0100	[thread overview]
Message-ID: <568D2733.4040304@pengutronix.de> (raw)
In-Reply-To: <20160105165410.GA6132@ravnborg.org>


[-- Attachment #1.1: Type: text/plain, Size: 2118 bytes --]

On 01/05/2016 05:54 PM, Sam Ravnborg wrote:
> On Tue, Jan 05, 2016 at 09:11:01AM +0100, Marc Kleine-Budde wrote:
>> From: Sascha Hauer <s.hauer@pengutronix.de>
>>
>> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
>> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> 
> The subject and the patch description could use some
> more love and care.

Good idea.

>> diff --git a/crypto/digest.c b/crypto/digest.c
>> index a90e4ff79f89..46600f246ece 100644
>> --- a/crypto/digest.c
>> +++ b/crypto/digest.c
>> @@ -116,7 +116,27 @@ static struct digest_algo *digest_algo_get_by_name(const char *name)
>>  	list_for_each_entry(tmp, &digests, list) {
>>  		if (strcmp(tmp->base.name, name) != 0)
>>  			continue;
>> -		
>> +
>> +		if (tmp->base.priority <= priority)
>> +			continue;
>> +
>> +		d = tmp;
>> +		priority = tmp->base.priority;
>> +	}
>> +
>> +	return d;
>> +}
>> +
>> +static struct digest_algo *digest_algo_get_by_algo(enum hash_algo algo)
>> +{
>> +	struct digest_algo *d = NULL;
>> +	struct digest_algo *tmp;
>> +	int priority = -1;
>> +
>> +	list_for_each_entry(tmp, &digests, list) {
>> +		if (tmp->base.algo != algo)
>> +			continue;
>> +
>>  		if (tmp->base.priority <= priority)
>>  			continue;
>>  
>> @@ -160,6 +180,27 @@ struct digest *digest_alloc(const char *name)
>>  }
>>  EXPORT_SYMBOL_GPL(digest_alloc);
>>  
>> +struct digest *digest_alloc_by_algo(enum hash_algo hash_algo)
>> +{
>> +	struct digest *d;
>> +	struct digest_algo *algo;
>> +
>> +	algo = digest_algo_get_by_algo(hash_algo);
>> +	if (!algo)
>> +		return NULL;
>> +
>> +	d = xzalloc(sizeof(*d));
>> +	d->algo = algo;
>> +	d->ctx = xzalloc(algo->ctx_length);
> 
> Neither allocations are checked for failure.

If xzalloc fails barebox will go into OOM and throw a backtrace.

Marc
-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2016-01-06 14:40 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-05  8:11 [PATCH 0/3] FIT Support Marc Kleine-Budde
2016-01-05  8:11 ` [PATCH 1/3] crypto: add enum Marc Kleine-Budde
2016-01-05 16:54   ` Sam Ravnborg
2016-01-06 14:39     ` Marc Kleine-Budde [this message]
2016-01-06 16:55       ` Sam Ravnborg
2016-01-05  8:11 ` [PATCH 2/3] crypto: add RSA support Marc Kleine-Budde
2016-01-05  8:11 ` [PATCH 3/3] bootm: add initial FIT support Marc Kleine-Budde
2016-01-05 10:28   ` Yegor Yefremov
2016-01-05 10:32     ` Marc Kleine-Budde
2016-01-05 10:40       ` Yegor Yefremov
2016-01-05 11:54         ` Marc Kleine-Budde
2016-01-05 13:05           ` Yegor Yefremov
2016-01-05 13:50             ` Marc Kleine-Budde
2016-01-05 13:58               ` Yegor Yefremov
2016-01-07 17:09               ` Jan Lübbe
2016-01-08 10:36                 ` Yegor Yefremov
2016-01-05 20:28   ` Trent Piepho
2016-01-06 16:09     ` Marc Kleine-Budde
2016-01-07 17:00       ` Jan Lübbe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=568D2733.4040304@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=kernel@pengutronix.de \
    --cc=sam@ravnborg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox