mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Emilio G. Cota" <cota@braap.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Martyn Welch <martyn.welch@ge.com>,
	Manohar Vanga <manohar.vanga@gmail.com>,
	"Emilio G. Cota" <cota@braap.org>,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: [PATCH] vme: add missing put_device() after device_register() fails
Date: Wed, 13 Feb 2013 13:47:54 -0500	[thread overview]
Message-ID: <1360781274-14405-1-git-send-email-cota@braap.org> (raw)

From: "Emilio G. Cota" <cota@braap.org>

put_device() must be called after device_register() fails,
since device_register() always initializes the refcount
on the device structure.

Signed-off-by: Emilio G. Cota <cota@braap.org>
---
 drivers/vme/vme.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c
index 95a9f71..5e6c7d7 100644
--- a/drivers/vme/vme.c
+++ b/drivers/vme/vme.c
@@ -1366,26 +1366,27 @@ static int __vme_register_driver_bus(struct vme_driver *drv,
 		err = device_register(&vdev->dev);
 		if (err)
 			goto err_reg;
 
 		if (vdev->dev.platform_data) {
 			list_add_tail(&vdev->drv_list, &drv->devices);
 			list_add_tail(&vdev->bridge_list, &bridge->devices);
 		} else
 			device_unregister(&vdev->dev);
 	}
 	return 0;
 
 err_reg:
+	put_device(&vdev->dev);
 	kfree(vdev);
 err_devalloc:
 	list_for_each_entry_safe(vdev, tmp, &drv->devices, drv_list) {
 		list_del(&vdev->drv_list);
 		list_del(&vdev->bridge_list);
 		device_unregister(&vdev->dev);
 	}
 	return err;
 }
 
 static int __vme_register_driver(struct vme_driver *drv, unsigned int ndevs)
 {
 	struct vme_bridge *bridge;
-- 
1.7.9.5


             reply	other threads:[~2013-02-13 19:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-13 18:47 Emilio G. Cota [this message]
2013-02-25 15:35 ` Martyn Welch

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=1360781274-14405-1-git-send-email-cota@braap.org \
    --to=cota@braap.org \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manohar.vanga@gmail.com \
    --cc=martyn.welch@ge.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

all inboxes | Powered by JetHome®