public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Krishna C Gudipati <kgudipat@brocade.com>
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: [patch] [SCSI] bfa: cleanup a memcpy()
Date: Thu, 11 Oct 2012 07:02:03 +0000	[thread overview]
Message-ID: <20121011070203.GG31607@elgon.mountain> (raw)

Smatch complains that we are writing more data than ->srlid_base
member can hold.  In fact, we are over writing the whole struct.  I've
re-written it to be a bit more clear and to silence the static checker
warning.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c
index 0116c10..a6dc18e 100644
--- a/drivers/scsi/bfa/bfa_ioc.c
+++ b/drivers/scsi/bfa/bfa_ioc.c
@@ -3624,11 +3624,9 @@ bfa_sfp_show_comp(struct bfa_sfp_s *sfp, struct bfi_mbmsg_s *msg)
 	bfa_trc(sfp, sfp->memtype);
 	if (sfp->memtype = BFI_SFP_MEM_DIAGEXT) {
 		bfa_trc(sfp, sfp->data_valid);
-		if (sfp->data_valid) {
-			u32	size = sizeof(struct sfp_mem_s);
-			u8 *des = (u8 *) &(sfp->sfpmem->srlid_base);
-			memcpy(des, sfp->dbuf_kva, size);
-		}
+		if (sfp->data_valid)
+			memcpy(sfp->sfpmem, sfp->dbuf_kva,
+					sizeof(*sfp->sfpmem));
 		/*
 		 * Queue completion callback.
 		 */

                 reply	other threads:[~2012-10-11  7:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20121011070203.GG31607@elgon.mountain \
    --to=dan.carpenter@oracle.com \
    --cc=JBottomley@parallels.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kgudipat@brocade.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.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