mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH master 1/2] fs: fail gracefully in get_mounted_path/get_cdev_by_mountpath
Date: Mon, 8 May 2023 15:18:38 +0200	[thread overview]
Message-ID: <20230508131838.GX29365@pengutronix.de> (raw)
In-Reply-To: <20230508074612.3313870-1-a.fatoum@pengutronix.de>

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@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 |



      parent reply	other threads:[~2023-05-08 13:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-08  7:46 Ahmad Fatoum
2023-05-08  7:46 ` [PATCH master 2/2] block: refuse registering block devices with absurdly large blocks Ahmad Fatoum
2023-05-08 13:18 ` Sascha Hauer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230508131838.GX29365@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox