mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: "Dr.-Ing. Martin Däumler SYS TEC electronic GmbH"
	<martin.daeumler@systec-electronic.com>
Cc: barebox@lists.infradead.org,
	"Daniel Krüger" <daniel.krueger@systec-electronic.com>,
	"Alexander Stein" <alexander.stein@systec-electronic.com>
Subject: Re: Crash after failed UBIFS mount
Date: Wed, 2 Mar 2016 11:00:34 +0100	[thread overview]
Message-ID: <20160302100034.GO9224@pengutronix.de> (raw)
In-Reply-To: <56D6B15B.2040206@systec-electronic.com>

Hi Martin,

On Wed, Mar 02, 2016 at 10:24:43AM +0100, Dr.-Ing. Martin Däumler SYS TEC electronic GmbH wrote:
> Hello,
> 
> we encountered a problem of barebox tag 2015.05.0, which is also
> reproducible with tag 2016.01.0. Mounting an UBIFS file system partition
> fails (correctly) and barebox crashes while cleaning up. The call hierarchy
> is
> as follows:
> 
> -mount() (fs/fs.c:1243): try to mount ubifs partition; call
> register_device()
> --register_device() (drivers/base/driver.c:138):
> ---match() (drivers/base/driver.c:117): look for a suitable device driver
> ----device_probe() (drivers/base/driver.c:82): ubifs partition fails to
> mount due to corrupted LEB
> ----device_probe(): delete device's 'active' list ('list_del(&dev->active)')
> ---match(): set device driver to NULL and return -1 to register_device()
> --register_device(): return 0 (success) to mount()
> -mount(): check device driver and call unregister_device() due to invalid
> driver
> --unregister_device() (drivers/base/driver.c:180): delete device's 'active'
> list the second time -> crash
> 
> Barebox does not crash if drivers/base/driver.c:92, i.e., list deletion in
> device_probe(), is removed. Is the removal of the list deletion a valid
> solution or does this have side effects?

This should be fixed with the following patch which currently sits in
the master branch.

Sascha

-----------------------8<-------------------------------------

From 46bb3a4d8490b318fbcfac7b69c217cec05d7a8f Mon Sep 17 00:00:00 2001
From: Sascha Hauer <s.hauer@pengutronix.de>
Date: Mon, 8 Feb 2016 11:31:00 +0100
Subject: [PATCH] driver: Fix unregister device after device probe failure

When a device probe fails the device is removed from the active list.
If then the device is unregistered afterwards it is removed from the
active list again resulting in a crash. To fix this initialize the
devices active list entry when removing it from the active list.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/base/driver.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index a70fbb2..c529296 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -101,6 +101,8 @@ int device_probe(struct device_d *dev)
 	}
 
 	list_del(&dev->active);
+	INIT_LIST_HEAD(&dev->active);
+
 	dev_err(dev, "probe failed: %s\n", strerror(-ret));
 
 	return ret;
@@ -258,6 +260,8 @@ static int device_probe_deferred(void)
 
 		list_for_each_entry_safe(dev, tmp, &deferred, active) {
 			list_del(&dev->active);
+			INIT_LIST_HEAD(&dev->active);
+
 			dev_dbg(dev, "re-probe device\n");
 			bus_for_each_driver(dev->bus, drv) {
 				if (match(drv, dev))
-- 
2.7.0

-- 
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:[~2016-03-02 10:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-02  9:24 Dr.-Ing. Martin Däumler SYS TEC electronic GmbH
2016-03-02 10:00 ` 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=20160302100034.GO9224@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=alexander.stein@systec-electronic.com \
    --cc=barebox@lists.infradead.org \
    --cc=daniel.krueger@systec-electronic.com \
    --cc=martin.daeumler@systec-electronic.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