aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn
diff options
context:
space:
mode:
authorGeliang Tang <geliangtang@163.com>2015-10-12 04:19:07 -0400
committerDavid S. Miller <davem@davemloft.net>2015-10-13 21:29:50 -0400
commitc3643885aa8a3c7cff3ba3269337f39361d76f76 (patch)
tree2966f6a46a49d415ca042793185cd49a833fe6e0 /drivers/isdn
parent4bdc3d66147b3a623b32216a45431d0cff005f50 (diff)
mISDN: use kstrdup() in dsp_pipeline_build
Use kstrdup instead of strlen-kmalloc-strcpy. Remove unneeded NULL test, it will be tested inside kstrdup. Remove 0 length string test, it has been tested in the caller of dsp_pipeline_build. Signed-off-by: Geliang Tang <geliangtang@163.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/isdn')
-rw-r--r--drivers/isdn/mISDN/dsp_pipeline.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/drivers/isdn/mISDN/dsp_pipeline.c b/drivers/isdn/mISDN/dsp_pipeline.c
index 8b1a66c6ca8a..e72b4e73cd61 100644
--- a/drivers/isdn/mISDN/dsp_pipeline.c
+++ b/drivers/isdn/mISDN/dsp_pipeline.c
@@ -235,7 +235,7 @@ void dsp_pipeline_destroy(struct dsp_pipeline *pipeline)
235 235
236int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg) 236int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg)
237{ 237{
238 int len, incomplete = 0, found = 0; 238 int incomplete = 0, found = 0;
239 char *dup, *tok, *name, *args; 239 char *dup, *tok, *name, *args;
240 struct dsp_element_entry *entry, *n; 240 struct dsp_element_entry *entry, *n;
241 struct dsp_pipeline_entry *pipeline_entry; 241 struct dsp_pipeline_entry *pipeline_entry;
@@ -247,17 +247,9 @@ int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg)
247 if (!list_empty(&pipeline->list)) 247 if (!list_empty(&pipeline->list))
248 _dsp_pipeline_destroy(pipeline); 248 _dsp_pipeline_destroy(pipeline);
249 249
250 if (!cfg) 250 dup = kstrdup(cfg, GFP_ATOMIC);
251 return 0;
252
253 len = strlen(cfg);
254 if (!len)
255 return 0;
256
257 dup = kmalloc(len + 1, GFP_ATOMIC);
258 if (!dup) 251 if (!dup)
259 return 0; 252 return 0;
260 strcpy(dup, cfg);
261 while ((tok = strsep(&dup, "|"))) { 253 while ((tok = strsep(&dup, "|"))) {
262 if (!strlen(tok)) 254 if (!strlen(tok))
263 continue; 255 continue;