mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Zahari Doychev <zahari.doychev@linux.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] drivers/mtd: fix NULL pointer dereference in partition lock/unlock
Date: Wed, 9 Jul 2014 07:31:36 +0200	[thread overview]
Message-ID: <20140709053136.GZ23235@pengutronix.de> (raw)
In-Reply-To: <a2949dd62538a64ec5689b63d6ff531620ceb198.1404734020.git.zahari.doychev@linux.com>

On Tue, Jul 08, 2014 at 09:37:35AM +0200, Zahari Doychev wrote:
> Some mtd device does not support lock and unlock functions. Adding this check
> avoids crashing when mtd_part_lock/unlock are called for such devices.
> 
> Signed-off-by: Zahari Doychev <zahari.doychev@linux.com>

Applied, thanks

Sascha

> ---
>  drivers/mtd/partition.c |    6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/mtd/partition.c b/drivers/mtd/partition.c
> index 5c0d46f..5a3d1ae 100644
> --- a/drivers/mtd/partition.c
> +++ b/drivers/mtd/partition.c
> @@ -51,6 +51,9 @@ static int mtd_part_erase(struct mtd_info *mtd, struct erase_info *instr)
>  
>  static int mtd_part_lock(struct mtd_info *mtd, loff_t offset, size_t len)
>  {
> +	if (!mtd->master->lock)
> +		return -ENOSYS;
> +
>  	if (!(mtd->flags & MTD_WRITEABLE))
>  		return -EROFS;
>  
> @@ -64,6 +67,9 @@ static int mtd_part_lock(struct mtd_info *mtd, loff_t offset, size_t len)
>  
>  static int mtd_part_unlock(struct mtd_info *mtd, loff_t offset, size_t len)
>  {
> +	if (!mtd->master->unlock)
> +		return -ENOSYS;
> +
>  	if (!(mtd->flags & MTD_WRITEABLE))
>  		return -EROFS;
>  
> -- 
> 1.7.9.5
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      reply	other threads:[~2014-07-09  5:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-08  7:37 [PATCH] fix mtd_part_lock/unlock Zahari Doychev
2014-07-08  7:37 ` [PATCH] drivers/mtd: fix NULL pointer dereference in partition lock/unlock Zahari Doychev
2014-07-09  5:31   ` 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=20140709053136.GZ23235@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=zahari.doychev@linux.com \
    /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