ASoC: simple-card: Add a NULL pointer check in asoc_simple_card_dai_link_of
Subsystems (4)
PATCH 1/1 ASoC: simple-card: Add a NULL pointer check in asoc_simple_card_dai_link_of
Make sure devm_kzalloc() succeeds.
--- sound/soc/generic/simple-card.c | 5 +++++ 1 file changed, 5 insertions(+)
sound/soc/generic/simple-card.c +5 -0
@@ -372,6 +372,11 @@ static int asoc_simple_card_dai_link_of(struct device_node *node,strlen (dai_link->cpu_dai_name) +strlen (dai_link->codec_dai_name) +2 , GFP_KERNEL); +if (!name) { + ret = -ENOMEM ; + goto dai_link_of_err; + } +sprintf (name,"%s-%s" , dai_link->cpu_dai_name, dai_link->codec_dai_name); dai_link->name = dai_link->stream_name = name;
Signature · 1 line
1.7.9.5
Quoted 1 line · Vishal Thanki
Make sure
devm_kzalloc()succeeds.
Applied, thanks.
Am 03.03.2015 14:29, schrieb Vishal Thanki:
Quoted 13 lines
Make sure
devm_kzalloc()succeeds.Signed-off-by Vishal Thanki <[email protected]>--- sound/soc/generic/simple-card.c | 5 +++++ 1 file changed, 5 insertions(+)sound/soc/generic/simple-card.c +0
-0@@ -372,6 +372,11 @@ static int asoc_simple_card_dai_link_of(struct device_node *node, strlen(dai_link->cpu_dai_name) +
sound/soc/generic/simple-card.c static int asoc_simple_card_dai_link_of(struct device_node *node, · line 382
Quoted 10 lines
sound/soc/generic/simple-card.c +5
-0strlen (dai_link->codec_dai_name) +2 , GFP_KERNEL); +if (!name) { + ret = -ENOMEM ; + goto dai_link_of_err; + } +sprintf (name,"%s-%s" , dai_link->cpu_dai_name, dai_link->codec_dai_name); dai_link->name = dai_link->stream_name = name;
maybe it is more simple to use kasprintf here ?
just my 2 cents,
wh
I am new to kasprintf. I think we need to make sure of freeing memory allocated using kasprintf.
Quoted 36 lines · walter harms
Am 03.03.2015 14:29, schrieb Vishal Thanki:
Review
Quoted 8 lines
Make sure
devm_kzalloc()succeeds.Signed-off-by Vishal Thanki <[email protected]>--- sound/soc/generic/simple-card.c | 5 +++++ 1 file changed, 5 insertions(+)(quoted diff) +0
-0
b/sound/soc/generic/simple-card.csound/soc/generic/simple-card.c static int asoc_simple_card_dai_link_of(struct
Quoted 4 lines
index f7c6734..fb550b5 100644
sound/soc/generic/simple-card.c +0
-0@@ -372,6 +372,11 @@ static int asoc_simple_card_dai_link_of(struct
device_node*node,sound/soc/generic/simple-card.c static int asoc_simple_card_dai_link_of(struct device_node *node, · line 382
Quoted 11 lines
sound/soc/generic/simple-card.c +5
-0strlen (dai_link->cpu_dai_name) +strlen (dai_link->codec_dai_name) +2 , GFP_KERNEL); +if (!name) { + ret = -ENOMEM ; + goto dai_link_of_err; + } +sprintf (name,"%s-%s" , dai_link->cpu_dai_name, dai_link->codec_dai_name); dai_link->name = dai_link->stream_name = name;maybe it is more simple to use kasprintf here ?
just my 2 cents,
wh
Quoted 2 lines · Vishal Thanki
I am new to kasprintf. I think we need to make sure of freeing memory allocated using kasprintf.
There is also devm_kasprintf().
But these are really two separate things. One thing is the missing NULL check, which is a bug fix and is fixed by your patch. The other thing is the conversion to kasprintf() which is a code cleanup and should be done in a separate patch.
- Lars
Am 05.03.2015 13:03, schrieb Lars-Peter Clausen:
Quoted 11 lines · Vishal Thanki
Quoted 2 lines
I am new to kasprintf. I think we need to make sure of freeing memory allocated using kasprintf.
There is also
devm_kasprintf().But these are really two separate things. One thing is the missing NULL check, which is a bug fix and is fixed by your patch. The other thing is the conversion to
kasprintf()which is a code cleanup and should be done in a separate patch.
hi,
thx for the hint:
never read about devm_kasprintf().
ntl my mail was intended as hint about asprintf() not about the patch.
re,
wh