mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-media@vger.kernel.org,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Olli Salonen <olli.salonen@iki.fi>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 3/4] [media] sp2: Adjust a jump target in sp2_probe()
Date: Fri, 1 Sep 2017 21:44:45 +0200	[thread overview]
Message-ID: <88ff94f8-ee01-7a11-f98e-92b3944dc930@users.sourceforge.net> (raw)
In-Reply-To: <6142ca34-fcda-f2b6-bc35-dbbde0d34378@users.sourceforge.net>

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

  parent reply	other threads:[~2017-09-01 19:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-01 19:41 [PATCH 0/4] [media] SP2: Adjustments for two function implementations SF Markus Elfring
2017-09-01 19:42 ` [PATCH 1/4] [media] sp2: Delete an error message for a failed memory allocation in sp2_probe() SF Markus Elfring
2017-09-01 19:43 ` [PATCH 2/4] [media] sp2: Improve a size determination " SF Markus Elfring
2017-09-01 19:44 ` SF Markus Elfring [this message]
2017-09-08 13:42   ` [PATCH 3/4] [media] sp2: Adjust a jump target " Hans Verkuil
2017-09-01 19:45 ` [PATCH 4/4] [media] sp2: Adjust three null pointer checks in sp2_exit() SF Markus Elfring

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=88ff94f8-ee01-7a11-f98e-92b3944dc930@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=olli.salonen@iki.fi \
    /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®