linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] staging: most: fix error comparison
@ 2015-11-22 17:00 Sudip Mukherjee
  2015-11-22 17:00 ` [PATCH 2/3] staging: most: return proper error Sudip Mukherjee
  2015-11-22 17:00 ` [PATCH 3/3] staging: most: fix id leak Sudip Mukherjee
  0 siblings, 2 replies; 5+ messages in thread
From: Sudip Mukherjee @ 2015-11-22 17:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, devel, Sudip Mukherjee

device_create() returns ERR_PTR on error, it does not return NULL.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
 drivers/staging/most/mostcore/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/most/mostcore/core.c b/drivers/staging/most/mostcore/core.c
index ed1ed25..07f11dd 100644
--- a/drivers/staging/most/mostcore/core.c
+++ b/drivers/staging/most/mostcore/core.c
@@ -1936,7 +1936,7 @@ static int __init most_init(void)
 
 	class_glue_dir =
 		device_create(most_class, NULL, 0, NULL, "mostcore");
-	if (!class_glue_dir)
+	if (IS_ERR(class_glue_dir))
 		goto exit_driver;
 
 	most_aim_kset =
-- 
1.9.1


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

* [PATCH 2/3] staging: most: return proper error
  2015-11-22 17:00 [PATCH 1/3] staging: most: fix error comparison Sudip Mukherjee
@ 2015-11-22 17:00 ` Sudip Mukherjee
  2016-02-07 22:14   ` Greg Kroah-Hartman
  2015-11-22 17:00 ` [PATCH 3/3] staging: most: fix id leak Sudip Mukherjee
  1 sibling, 1 reply; 5+ messages in thread
From: Sudip Mukherjee @ 2015-11-22 17:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, devel, Sudip Mukherjee

We were returning ENOMEM on all types of errors. Lets return the actual
error code. At the same time remove the label which became unused as a
result of this patch.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
 drivers/staging/most/mostcore/core.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/most/mostcore/core.c b/drivers/staging/most/mostcore/core.c
index 07f11dd..619d558 100644
--- a/drivers/staging/most/mostcore/core.c
+++ b/drivers/staging/most/mostcore/core.c
@@ -1913,31 +1913,38 @@ EXPORT_SYMBOL_GPL(most_resume_enqueue);
 
 static int __init most_init(void)
 {
+	int err;
+
 	pr_info("init()\n");
 	INIT_LIST_HEAD(&instance_list);
 	INIT_LIST_HEAD(&aim_list);
 	mutex_init(&deregister_mutex);
 	ida_init(&mdev_id);
 
-	if (bus_register(&most_bus)) {
+	err = bus_register(&most_bus);
+	if (err) {
 		pr_info("Cannot register most bus\n");
-		goto exit;
+		return err;
 	}
 
 	most_class = class_create(THIS_MODULE, "most");
 	if (IS_ERR(most_class)) {
 		pr_info("No udev support.\n");
+		err = PTR_ERR(most_class);
 		goto exit_bus;
 	}
-	if (driver_register(&mostcore)) {
+	err = driver_register(&mostcore);
+	if (err) {
 		pr_info("Cannot register core driver\n");
 		goto exit_class;
 	}
 
 	class_glue_dir =
 		device_create(most_class, NULL, 0, NULL, "mostcore");
-	if (IS_ERR(class_glue_dir))
+	if (IS_ERR(class_glue_dir)) {
+		err = -ENOMEM;
 		goto exit_driver;
+	}
 
 	most_aim_kset =
 		kset_create_and_add("aims", NULL, &class_glue_dir->kobj);
@@ -1946,8 +1953,10 @@ static int __init most_init(void)
 
 	most_inst_kset =
 		kset_create_and_add("devices", NULL, &class_glue_dir->kobj);
-	if (!most_inst_kset)
+	if (!most_inst_kset) {
+		err = -ENOMEM;
 		goto exit_driver_kset;
+	}
 
 	return 0;
 
@@ -1961,8 +1970,7 @@ exit_class:
 	class_destroy(most_class);
 exit_bus:
 	bus_unregister(&most_bus);
-exit:
-	return -ENOMEM;
+	return err;
 }
 
 static void __exit most_exit(void)
-- 
1.9.1


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

* [PATCH 3/3] staging: most: fix id leak
  2015-11-22 17:00 [PATCH 1/3] staging: most: fix error comparison Sudip Mukherjee
  2015-11-22 17:00 ` [PATCH 2/3] staging: most: return proper error Sudip Mukherjee
@ 2015-11-22 17:00 ` Sudip Mukherjee
  1 sibling, 0 replies; 5+ messages in thread
From: Sudip Mukherjee @ 2015-11-22 17:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, devel, Sudip Mukherjee

If create_most_inst_obj() fails we returned an error pointer but we
missed releasing id.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
 drivers/staging/most/mostcore/core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/most/mostcore/core.c b/drivers/staging/most/mostcore/core.c
index 619d558..6210257 100644
--- a/drivers/staging/most/mostcore/core.c
+++ b/drivers/staging/most/mostcore/core.c
@@ -1762,6 +1762,7 @@ struct kobject *most_register_interface(struct most_interface *iface)
 	inst = create_most_inst_obj(name);
 	if (!inst) {
 		pr_info("Failed to allocate interface instance\n");
+		ida_simple_remove(&mdev_id, id);
 		return ERR_PTR(-ENOMEM);
 	}
 
-- 
1.9.1


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

* Re: [PATCH 2/3] staging: most: return proper error
  2015-11-22 17:00 ` [PATCH 2/3] staging: most: return proper error Sudip Mukherjee
@ 2016-02-07 22:14   ` Greg Kroah-Hartman
  2016-02-08 18:10     ` Sudip Mukherjee
  0 siblings, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2016-02-07 22:14 UTC (permalink / raw)
  To: Sudip Mukherjee; +Cc: linux-kernel, devel

On Sun, Nov 22, 2015 at 10:30:55PM +0530, Sudip Mukherjee wrote:
> We were returning ENOMEM on all types of errors. Lets return the actual
> error code. At the same time remove the label which became unused as a
> result of this patch.
> 
> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> ---
>  drivers/staging/most/mostcore/core.c | 22 +++++++++++++++-------
>  1 file changed, 15 insertions(+), 7 deletions(-)

This and patch 3/3 don't apply anymore :(

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

* Re: [PATCH 2/3] staging: most: return proper error
  2016-02-07 22:14   ` Greg Kroah-Hartman
@ 2016-02-08 18:10     ` Sudip Mukherjee
  0 siblings, 0 replies; 5+ messages in thread
From: Sudip Mukherjee @ 2016-02-08 18:10 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, devel

On Sun, Feb 07, 2016 at 02:14:56PM -0800, Greg Kroah-Hartman wrote:
> On Sun, Nov 22, 2015 at 10:30:55PM +0530, Sudip Mukherjee wrote:
> > We were returning ENOMEM on all types of errors. Lets return the actual
> > error code. At the same time remove the label which became unused as a
> > result of this patch.
> > 
> > Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> > ---
> >  drivers/staging/most/mostcore/core.c | 22 +++++++++++++++-------
> >  1 file changed, 15 insertions(+), 7 deletions(-)
> 
> This and patch 3/3 don't apply anymore :(

This one I have rebased and sent again but looks like 3/3 has already
been done by a later patch.

regards
sudip

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

end of thread, other threads:[~2016-02-08 18:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-22 17:00 [PATCH 1/3] staging: most: fix error comparison Sudip Mukherjee
2015-11-22 17:00 ` [PATCH 2/3] staging: most: return proper error Sudip Mukherjee
2016-02-07 22:14   ` Greg Kroah-Hartman
2016-02-08 18:10     ` Sudip Mukherjee
2015-11-22 17:00 ` [PATCH 3/3] staging: most: fix id leak Sudip Mukherjee

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).