linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Bounine, Alexandre" <Alexandre.Bounine@idt.com>
To: "Dan Carpenter" <error27@gmail.com>,
	"Matt Porter" <mporter@kernel.crashing.org>
Cc: <linux-kernel@vger.kernel.org>, <kernel-janitors@vger.kernel.org>
Subject: RE: [patch] rapidio: potential null deref on failure path
Date: Mon, 21 Mar 2011 05:49:06 -0700	[thread overview]
Message-ID: <0CE8B6BE3C4AD74AB97D9D29BD24E55201A588F5@CORPEXCH1.na.ads.idt.com> (raw)
In-Reply-To: <20110319044032.GC2008@bicker>

Better to combine both conditions:

if (rio_is_switch(rdev) && rswitch->route_table))
 		kfree(rswitch->route_table);

Because there is situation when routine fails to allocate route_table
for a switch.

Alex. 


-----Original Message-----
From: Dan Carpenter [mailto:error27@gmail.com] 
Sent: Saturday, March 19, 2011 12:41 AM
To: Matt Porter
Cc: Bounine, Alexandre; linux-kernel@vger.kernel.org;
kernel-janitors@vger.kernel.org
Subject: [patch] rapidio: potential null deref on failure path

If rio is not a switch then "rswitch" is null.

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c
index a50391b..3a59d5f 100644
--- a/drivers/rapidio/rio-scan.c
+++ b/drivers/rapidio/rio-scan.c
@@ -517,7 +517,7 @@ static struct rio_dev __devinit
*rio_setup_device(struct rio_net *net,
 	return rdev;
 
 cleanup:
-	if (rswitch->route_table)
+	if (rio_is_switch(rdev))
 		kfree(rswitch->route_table);
 
 	kfree(rdev);

  reply	other threads:[~2011-03-21 12:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-19  4:40 [patch] rapidio: potential null deref on failure path Dan Carpenter
2011-03-21 12:49 ` Bounine, Alexandre [this message]
2011-03-21 14:59   ` Dan Carpenter
2011-03-21 15:15     ` Bounine, Alexandre
2011-03-21 15:52       ` Dan Carpenter
2011-03-21 16:05         ` Bounine, Alexandre
2011-03-21 18:34 ` Bounine, Alexandre

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=0CE8B6BE3C4AD74AB97D9D29BD24E55201A588F5@CORPEXCH1.na.ads.idt.com \
    --to=alexandre.bounine@idt.com \
    --cc=error27@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mporter@kernel.crashing.org \
    /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;
as well as URLs for NNTP newsgroup(s).