linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] firmware class: remove from pending list on load failure
@ 2015-01-05 15:41 Sasha Levin
  2015-01-07  4:52 ` Ming Lei
  0 siblings, 1 reply; 7+ messages in thread
From: Sasha Levin @ 2015-01-05 15:41 UTC (permalink / raw)
  To: linux-kernel; +Cc: Sasha Levin, Ming Lei, Greg Kroah-Hartman

If we failed loading the firmware we have to make sure it leaves the pending
list if abort wasn't executed for it.

Otherwise we'd free an object still on the pending list and corrupt it.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 drivers/base/firmware_class.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 58470c3..8ccf6cf4 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -929,9 +929,18 @@ static int _request_firmware_load(struct firmware_priv *fw_priv,
 	cancel_delayed_work_sync(&fw_priv->timeout_work);
 	if (is_fw_load_aborted(buf))
 		retval = -EAGAIN;
-	else if (!buf->data)
+	else if (!buf->data) {
 		retval = -ENOMEM;
 
+		/*
+		 * We failed loading, but abort was never done so we
+		 * need to remove it from the pending list ourselves.
+		 */
+		mutex_lock(&fw_lock);
+		list_del_init(&buf->pending_list);
+		mutex_unlock(&fw_lock);
+	}
+
 	device_remove_file(f_dev, &dev_attr_loading);
 err_del_bin_attr:
 	device_remove_bin_file(f_dev, &firmware_attr_data);
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-01-08  4:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-05 15:41 [PATCH] firmware class: remove from pending list on load failure Sasha Levin
2015-01-07  4:52 ` Ming Lei
2015-01-07 16:39   ` Sasha Levin
2015-01-08  2:15     ` Ming Lei
2015-01-08  2:37       ` Sasha Levin
2015-01-08  3:06         ` Ming Lei
2015-01-08  4:36           ` Ming Lei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).