Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1632796
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [alsa-devel] [PATCH 1/3] ASoC: simple-card: Use devm_kcalloc() in asoc_simple_card_parse_aux_devs() |
| Date | 2017-04-28 12:50 +0200 |
| Message-ID | <tBbDk-67E-5@gated-at.bofh.it> (permalink) |
| References | <tAuRI-2H8-3@gated-at.bofh.it> <tAuRI-2H8-7@gated-at.bofh.it> <tB9UT-53z-45@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
>> @@ -334,8 +334,8 @@ static int asoc_simple_card_parse_aux_devs(struct device_node *node, >> if (n <= 0) >> return -EINVAL; >> >> - card->aux_dev = devm_kzalloc(dev, >> - n * sizeof(*card->aux_dev), GFP_KERNEL); >> + card->aux_dev = devm_kcalloc(dev, n, sizeof(*card->aux_dev), >> + GFP_KERNEL); > > Do you realize that this change has absolutely no value We can have different software development opinions about such a source code adjustment. Does it improve the indentation for the parameters which are passed to this function call? > and just makes the code slower (one more test in the allocation path)? Do we stumble on a target conflict for the shown implementation detail? Does the previous size calculation contain the general possibility for an integer overflow? https://cwe.mitre.org/data/definitions/190.html The value for the variable “len” (and also “n”) might be small enough so that the computed value will usually not exceed the data type limit in this use case. Regards, Markus
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/3] ASoC: simple-card: Fine-tuning for three function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-26 15:10 +0200
[PATCH 2/3] ASoC: simple-card: Use devm_kcalloc() in asoc_simple_card_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-26 15:10 +0200
[PATCH 1/3] ASoC: simple-card: Use devm_kcalloc() in asoc_simple_card_parse_aux_devs() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-26 15:10 +0200
Re: [alsa-devel] [PATCH 1/3] ASoC: simple-card: Use devm_kcalloc() in asoc_simple_card_parse_aux_devs() Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2017-04-28 11:00 +0200
Re: [alsa-devel] [PATCH 1/3] ASoC: simple-card: Use devm_kcalloc() in asoc_simple_card_parse_aux_devs() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-28 12:50 +0200
[PATCH 3/3] ASoC: simple-scu-card: Use devm_kcalloc() in asoc_simple_card_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-26 15:10 +0200
csiph-web