Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

stm class: Fix a double free in stm_register_device()

The put_device(&stm->dev) call will trigger stm_device_release() which
frees "stm" so the vfree(stm) on the next line is a double free.

Fixes: 389b6699a2aa ("stm class: Fix stm device initialization order")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Link: https://lore.kernel.org/r/20240429130119.1518073-2-alexander.shishkin@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Dan Carpenter and committed by
Greg Kroah-Hartman
3df46386 1565fce9

+6 -5
+6 -5
drivers/hwtracing/stm/core.c
··· 868 868 return -ENOMEM; 869 869 870 870 stm->major = register_chrdev(0, stm_data->name, &stm_fops); 871 - if (stm->major < 0) 872 - goto err_free; 871 + if (stm->major < 0) { 872 + err = stm->major; 873 + vfree(stm); 874 + return err; 875 + } 873 876 874 877 device_initialize(&stm->dev); 875 878 stm->dev.devt = MKDEV(stm->major, 0); ··· 916 913 err_device: 917 914 unregister_chrdev(stm->major, stm_data->name); 918 915 919 - /* matches device_initialize() above */ 916 + /* calls stm_device_release() */ 920 917 put_device(&stm->dev); 921 - err_free: 922 - vfree(stm); 923 918 924 919 return err; 925 920 }