Welcome to Soft32 Linux Forums!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

[PATCH -2nd repost 1/4] SCSI: aacraid, fix memory leak

 
   Soft32 Home -> Linux -> Kernel RSS
Next:  [GIT PULL] x86 fixes  
Author Message
Jiri Slaby

External


Since: Nov 04, 2006
Posts: 520



(Msg. 1) Posted: Wed Nov 04, 2009 11:20 am
Post subject: [PATCH -2nd repost 1/4] SCSI: aacraid, fix memory leak
Archived from groups: linux>kernel (more info?)

Stanse found a memory leak on one fail path in aac_send_raw_srb. Add kfree
there.

Signed-off-by: Jiri Slaby <jirislaby RemoveThis @gmail.com>
Cc: James E.J. Bottomley <James.Bottomley RemoveThis @suse.de>
---
drivers/scsi/aacraid/commctrl.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
index 0391d75..5c9a8be 100644
--- a/drivers/scsi/aacraid/commctrl.c
+++ b/drivers/scsi/aacraid/commctrl.c
@@ -649,6 +649,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
AAC_OPT_NEW_COMM) ?
(dev->scsi_host_ptr->max_sectors << 9) :
65536) {
+ kfree (usg);
rcode = -EINVAL;
goto cleanup;
}
--
1.6.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo RemoveThis @vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to top
Login to vote
Jiri Slaby

External


Since: Nov 04, 2006
Posts: 520



(Msg. 2) Posted: Wed Nov 04, 2009 11:20 am
Post subject: [PATCH -2nd repost 2/4] SCSI: remove unnecessary NULL test [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Stanse found that c3cn is poked many times around in
cxgb3i_conn_pdu_ready, there is no need to check if it is NULL.

Remove the test.

Signed-off-by: Jiri Slaby <jirislaby DeleteThis @gmail.com>
Cc: James E.J. Bottomley <James.Bottomley DeleteThis @suse.de>
---
drivers/scsi/cxgb3i/cxgb3i_pdu.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/cxgb3i/cxgb3i_pdu.c b/drivers/scsi/cxgb3i/cxgb3i_pdu.c
index 7091050..64bbc28 100644
--- a/drivers/scsi/cxgb3i/cxgb3i_pdu.c
+++ b/drivers/scsi/cxgb3i/cxgb3i_pdu.c
@@ -461,10 +461,8 @@ void cxgb3i_conn_pdu_ready(struct s3_conn *c3cn)
skb = skb_peek(&c3cn->receive_queue);
}
read_unlock(&c3cn->callback_lock);
- if (c3cn) {
- c3cn->copied_seq += read;
- cxgb3i_c3cn_rx_credits(c3cn, read);
- }
+ c3cn->copied_seq += read;
+ cxgb3i_c3cn_rx_credits(c3cn, read);
conn->rxdata_octets += read;

if (err) {
--
1.6.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo DeleteThis @vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to top
Login to vote
Jiri Slaby

External


Since: Nov 04, 2006
Posts: 520



(Msg. 3) Posted: Wed Nov 04, 2009 11:20 am
Post subject: [PATCH -2nd repost 4/4] SCSI: scsi_lib, fix potential NULL dereference [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Stanse found a potential NULL dereference in scsi_kill_request.

Instead of triggering BUG() in 'if (unlikely(cmd == NULL))' branch,
the kernel will Oops earlier on cmd dereference.

Move the dereferences after the if.

Signed-off-by: Jiri Slaby <jirislaby.RemoveThis@gmail.com>
Cc: James E.J. Bottomley <James.Bottomley.RemoveThis@suse.de>
---
drivers/scsi/scsi_lib.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index ed98279..47ee130 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1359,9 +1359,9 @@ static int scsi_lld_busy(struct request_queue *q)
static void scsi_kill_request(struct request *req, struct request_queue *q)
{
struct scsi_cmnd *cmd = req->special;
- struct scsi_device *sdev = cmd->device;
- struct scsi_target *starget = scsi_target(sdev);
- struct Scsi_Host *shost = sdev->host;
+ struct scsi_device *sdev;
+ struct scsi_target *starget;
+ struct Scsi_Host *shost;

blk_start_request(req);

@@ -1371,6 +1371,9 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
BUG();
}

+ sdev = cmd->device;
+ starget = scsi_target(sdev);
+ shost = sdev->host;
scsi_init_cmd_errh(cmd);
cmd->result = DID_NO_CONNECT << 16;
atomic_inc(&cmd->device->iorequest_cnt);
--
1.6.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo.RemoveThis@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to top
Login to vote
Mike Christie

External


Since: Dec 21, 2006
Posts: 16



(Msg. 4) Posted: Wed Nov 04, 2009 11:20 am
Post subject: Re: [PATCH -2nd repost 2/4] SCSI: remove unnecessary NULL test [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Adding Karen and removing adaptec since this is chelsio's driver.

Jiri Slaby wrote:
> Stanse found that c3cn is poked many times around in
> cxgb3i_conn_pdu_ready, there is no need to check if it is NULL.
>
> Remove the test.
>
> Signed-off-by: Jiri Slaby <jirislaby.TakeThisOut@gmail.com>
> Cc: James E.J. Bottomley <James.Bottomley.TakeThisOut@suse.de>
> ---
> drivers/scsi/cxgb3i/cxgb3i_pdu.c | 6 ++----
> 1 files changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/scsi/cxgb3i/cxgb3i_pdu.c b/drivers/scsi/cxgb3i/cxgb3i_pdu.c
> index 7091050..64bbc28 100644
> --- a/drivers/scsi/cxgb3i/cxgb3i_pdu.c
> +++ b/drivers/scsi/cxgb3i/cxgb3i_pdu.c
> @@ -461,10 +461,8 @@ void cxgb3i_conn_pdu_ready(struct s3_conn *c3cn)
> skb = skb_peek(&c3cn->receive_queue);
> }
> read_unlock(&c3cn->callback_lock);
> - if (c3cn) {
> - c3cn->copied_seq += read;
> - cxgb3i_c3cn_rx_credits(c3cn, read);
> - }
> + c3cn->copied_seq += read;
> + cxgb3i_c3cn_rx_credits(c3cn, read);
> conn->rxdata_octets += read;
>
> if (err) {

Looks ok to me. The null check was useless since we access c3cn all over
the function and would have oopsed before we got there.

Reviewed-by: Mike Christie <michaelc.TakeThisOut@cs.wisc.edu>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo.TakeThisOut@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to top
Login to vote
Karen Xie

External


Since: Nov 05, 2009
Posts: 1



(Msg. 5) Posted: Thu Nov 05, 2009 7:21 am
Post subject: RE: [PATCH -2nd repost 2/4] SCSI: remove unnecessary NULL test [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Yes, the check is not necessary.

Thanks,
Karen

-----Original Message-----
From: linux-scsi-owner RemoveThis @vger.kernel.org
[mailto:linux-scsi-owner@vger.kernel.org] On Behalf Of Jiri Slaby
Sent: Wednesday, November 04, 2009 8:15 AM
To: James.Bottomley RemoveThis @suse.de
Cc: aacraid RemoveThis @adaptec.com; james.smart RemoveThis @emulex.com;
linux-scsi RemoveThis @vger.kernel.org; linux-kernel RemoveThis @vger.kernel.org; Jiri Slaby
Subject: [PATCH -2nd repost 2/4] SCSI: remove unnecessary NULL test

Stanse found that c3cn is poked many times around in
cxgb3i_conn_pdu_ready, there is no need to check if it is NULL.

Remove the test.

Signed-off-by: Jiri Slaby <jirislaby RemoveThis @gmail.com>
Cc: James E.J. Bottomley <James.Bottomley RemoveThis @suse.de>
---
drivers/scsi/cxgb3i/cxgb3i_pdu.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/cxgb3i/cxgb3i_pdu.c
b/drivers/scsi/cxgb3i/cxgb3i_pdu.c
index 7091050..64bbc28 100644
--- a/drivers/scsi/cxgb3i/cxgb3i_pdu.c
+++ b/drivers/scsi/cxgb3i/cxgb3i_pdu.c
@@ -461,10 +461,8 @@ void cxgb3i_conn_pdu_ready(struct s3_conn *c3cn)
skb = skb_peek(&c3cn->receive_queue);
}
read_unlock(&c3cn->callback_lock);
- if (c3cn) {
- c3cn->copied_seq += read;
- cxgb3i_c3cn_rx_credits(c3cn, read);
- }
+ c3cn->copied_seq += read;
+ cxgb3i_c3cn_rx_credits(c3cn, read);
conn->rxdata_octets += read;

if (err) {
--
1.6.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo RemoveThis @vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo RemoveThis @vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to top
Login to vote
Display posts from previous:   
Related Topics:
[PATCH] [scsi] lpfc: potential leak in lpfc_sli_hbqbuf_fil.. - If lpfc_hbq_alloc() fails, an hbq_buffer is leaked. Found by Coverity (1775). Signed-off-by: Florin Malita..

[PATCH] fix memory leak dma_declare_coherent_memory() - Hi, This patch has fixed memory leak in dma_declare_coherent_memory(). When it goes to free1_out, dev->dma_mem has ...

[PATCH] Memory leak in tpm_ascii_bios_measurements_open() .. - Ehlo, Coverity found a memory leak in tpm_ascii_bios_measurements_open(). If "read_log(log)" fails, then we...

[PATCH] Fix potential memory leak in tipc_named_node_up() - There seems to be a memory leak in net/tipc/name_distr.c::tipc_named_node_up() The function, with comments, is this : ...

[PATCH] fix memory leak in UBI scanning unit - In drivers/mtd/ubi/scan.c::paranoid_check_si() there's a memory leak. If the call err = ubi_io_is_bad(ubi, pnum);..

[PATCH][XFS][resend] fix memory leak in xfs_inactive() - (this is back from May 16 2007, resending since it doesn't look like the patch ever made it in anywhere) The Coverit...
       Soft32 Home -> Linux -> Kernel All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Categories:
 Windows
  Linux
 Mac
 PDA


[ Contact us | Terms of Service/Privacy Policy ]