|
@@ -361,7 +361,7 @@ static int stm_char_open(struct inode *inode, struct file *file)
|
|
struct stm_file *stmf;
|
|
struct stm_file *stmf;
|
|
struct device *dev;
|
|
struct device *dev;
|
|
unsigned int major = imajor(inode);
|
|
unsigned int major = imajor(inode);
|
|
- int err = -ENODEV;
|
|
|
|
|
|
+ int err = -ENOMEM;
|
|
|
|
|
|
dev = class_find_device(&stm_class, NULL, &major, major_match);
|
|
dev = class_find_device(&stm_class, NULL, &major, major_match);
|
|
if (!dev)
|
|
if (!dev)
|
|
@@ -369,8 +369,9 @@ static int stm_char_open(struct inode *inode, struct file *file)
|
|
|
|
|
|
stmf = kzalloc(sizeof(*stmf), GFP_KERNEL);
|
|
stmf = kzalloc(sizeof(*stmf), GFP_KERNEL);
|
|
if (!stmf)
|
|
if (!stmf)
|
|
- return -ENOMEM;
|
|
|
|
|
|
+ goto err_put_device;
|
|
|
|
|
|
|
|
+ err = -ENODEV;
|
|
stm_output_init(&stmf->output);
|
|
stm_output_init(&stmf->output);
|
|
stmf->stm = to_stm_device(dev);
|
|
stmf->stm = to_stm_device(dev);
|
|
|
|
|
|
@@ -382,9 +383,10 @@ static int stm_char_open(struct inode *inode, struct file *file)
|
|
return nonseekable_open(inode, file);
|
|
return nonseekable_open(inode, file);
|
|
|
|
|
|
err_free:
|
|
err_free:
|
|
|
|
+ kfree(stmf);
|
|
|
|
+err_put_device:
|
|
/* matches class_find_device() above */
|
|
/* matches class_find_device() above */
|
|
put_device(dev);
|
|
put_device(dev);
|
|
- kfree(stmf);
|
|
|
|
|
|
|
|
return err;
|
|
return err;
|
|
}
|
|
}
|