[PATCH master 1/2] fs: fail gracefully in get_mounted_path/get_cdev_by_mountpath
Sascha Hauer
sha at pengutronix.de
Mon May 8 06:18:38 PDT 2023
On Mon, May 08, 2023 at 09:46:11AM +0200, Ahmad Fatoum wrote:
> get_fsdevice_by_path will return NULL if no file system was mounted at
> location. Returned pointer was dereferenced unconditionally, potentially
> leading to null pointer dereference. Fix this.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
> ---
> fs/fs.c | 4 ++++
> 1 file changed, 4 insertions(+)
Applied, thanks
Sascha
>
> diff --git a/fs/fs.c b/fs/fs.c
> index 65e4c661b9ce..368458cc54f8 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -240,6 +240,8 @@ struct cdev *get_cdev_by_mountpath(const char *path)
> struct fs_device *fsdev;
>
> fsdev = get_fsdevice_by_path(path);
> + if (!fsdev)
> + return NULL;
>
> return fsdev->cdev;
> }
> @@ -249,6 +251,8 @@ char *get_mounted_path(const char *path)
> struct fs_device *fdev;
>
> fdev = get_fsdevice_by_path(path);
> + if (!fdev)
> + return NULL;
>
> return fdev->path;
> }
> --
> 2.39.2
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list