* [patch] [SCSI] bfa: cleanup a memcpy()
@ 2012-10-11 7:02 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2012-10-11 7:02 UTC (permalink / raw)
To: Krishna C Gudipati
Cc: James E.J. Bottomley, linux-scsi, linux-kernel, kernel-janitors
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.
*/
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2012-10-11 7:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-11 7:02 [patch] [SCSI] bfa: cleanup a memcpy() Dan Carpenter
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).