Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1725314

[PATCH 3/4] [media] sp2: Adjust a jump target in sp2_probe()

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 3/4] [media] sp2: Adjust a jump target in sp2_probe()
Date 2017-09-01 21:50 +0200
Message-ID <ul06Z-15q-5@gated-at.bofh.it> (permalink)
References <ul06Z-15q-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 1 Sep 2017 21:08:38 +0200

* Adjust a jump target so that a null pointer will not be passed to a call
  of the function "kfree".

* Move this function call into an if branch.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/dvb-frontends/sp2.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/media/dvb-frontends/sp2.c b/drivers/media/dvb-frontends/sp2.c
index dd556012ceb6..b2a7a54174ae 100644
--- a/drivers/media/dvb-frontends/sp2.c
+++ b/drivers/media/dvb-frontends/sp2.c
@@ -384,7 +384,7 @@ static int sp2_probe(struct i2c_client *client,
 	s = kzalloc(sizeof(*s), GFP_KERNEL);
 	if (!s) {
 		ret = -ENOMEM;
-		goto err;
+		goto report_failure;
 	}
 
 	s->client = client;
@@ -395,15 +395,16 @@ static int sp2_probe(struct i2c_client *client,
 	i2c_set_clientdata(client, s);
 
 	ret = sp2_init(s);
-	if (ret)
-		goto err;
+	if (ret) {
+		kfree(s);
+		goto report_failure;
+	}
 
 	dev_info(&s->client->dev, "CIMaX SP2 successfully attached\n");
 	return 0;
-err:
-	dev_dbg(&client->dev, "init failed=%d\n", ret);
-	kfree(s);
 
+report_failure:
+	dev_dbg(&client->dev, "init failed=%d\n", ret);
 	return ret;
 }
 
-- 
2.14.1

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH 3/4] [media] sp2: Adjust a jump target in sp2_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-09-01 21:50 +0200
  Re: [PATCH 3/4] [media] sp2: Adjust a jump target in sp2_probe() Hans Verkuil <hverkuil@xs4all.nl> - 2017-09-08 15:50 +0200

csiph-web