aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwtracing/stm/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwtracing/stm/core.c')
-rw-r--r--drivers/hwtracing/stm/core.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c
index 51f81d64ca37..a6ea387b5b00 100644
--- a/drivers/hwtracing/stm/core.c
+++ b/drivers/hwtracing/stm/core.c
@@ -361,7 +361,7 @@ static int stm_char_open(struct inode *inode, struct file *file)
361 struct stm_file *stmf; 361 struct stm_file *stmf;
362 struct device *dev; 362 struct device *dev;
363 unsigned int major = imajor(inode); 363 unsigned int major = imajor(inode);
364 int err = -ENODEV; 364 int err = -ENOMEM;
365 365
366 dev = class_find_device(&stm_class, NULL, &major, major_match); 366 dev = class_find_device(&stm_class, NULL, &major, major_match);
367 if (!dev) 367 if (!dev)
@@ -369,8 +369,9 @@ static int stm_char_open(struct inode *inode, struct file *file)
369 369
370 stmf = kzalloc(sizeof(*stmf), GFP_KERNEL); 370 stmf = kzalloc(sizeof(*stmf), GFP_KERNEL);
371 if (!stmf) 371 if (!stmf)
372 return -ENOMEM; 372 goto err_put_device;
373 373
374 err = -ENODEV;
374 stm_output_init(&stmf->output); 375 stm_output_init(&stmf->output);
375 stmf->stm = to_stm_device(dev); 376 stmf->stm = to_stm_device(dev);
376 377
@@ -382,9 +383,10 @@ static int stm_char_open(struct inode *inode, struct file *file)
382 return nonseekable_open(inode, file); 383 return nonseekable_open(inode, file);
383 384
384err_free: 385err_free:
386 kfree(stmf);
387err_put_device:
385 /* matches class_find_device() above */ 388 /* matches class_find_device() above */
386 put_device(dev); 389 put_device(dev);
387 kfree(stmf);
388 390
389 return err; 391 return err;
390} 392}