public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Jesper Juhl <jesper.juhl@gmail.com>
To: linux-scsi@vger.kernel.org
Cc: Luben Tuikov <luben_tuikov@adaptec.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Jesper Juhl <jesper.juhl@gmail.com>
Subject: [PATCH] Fix problem with size of allocation in libsas
Date: Mon, 12 Nov 2007 00:24:54 +0100	[thread overview]
Message-ID: <200711120024.54773.jesper.juhl@gmail.com> (raw)

From: Jesper Juhl <jesper.juhl@gmail.com>

in sas_get_phy_change_count(), the line
	disc_resp = alloc_smp_resp(DISCOVER_RESP_SIZE);
will allocate 56 bytes due to this define:
	#define DISCOVER_RESP_SIZE 56
But, the struct is actually 60 bytes in size.

So change the define to be 
	#define DISCOVER_RESP_SIZE sizeof(struct smp_resp)
so we always get the correct size even when people 
fiddle with the structure.

This change also fixes the same problem in 
sas_get_phy_attached_sas_addr()

(Found by the Coverity checker. Compile tested only)


Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---

 sas_expander.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index 8727436..a666cb1 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -211,7 +211,7 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id,
 }
 
 #define DISCOVER_REQ_SIZE  16
-#define DISCOVER_RESP_SIZE 56
+#define DISCOVER_RESP_SIZE sizeof(struct smp_resp)
 
 static int sas_ex_phy_discover_helper(struct domain_device *dev, u8 *disc_req,
 				      u8 *disc_resp, int single)




             reply	other threads:[~2007-11-11 23:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-11 23:24 Jesper Juhl [this message]
2007-11-12  0:00 ` [PATCH] Fix problem with size of allocation in libsas James Bottomley
2007-11-12  0:13   ` Jesper Juhl
2007-11-12  0:37     ` James Bottomley
2007-11-12  0:48       ` Jesper Juhl
2007-11-12  0:33   ` Douglas Gilbert
2007-11-12  0:45     ` James Bottomley

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=200711120024.54773.jesper.juhl@gmail.com \
    --to=jesper.juhl@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=luben_tuikov@adaptec.com \
    /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