Skip to contentSkip to conversation

bfa: cleanup a memcpy()

PATCH New Dan Carpenter 1 participant 1 message Oct 11, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bfa: cleanup a memcpy()

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.

drivers/scsi/bfa/bfa_ioc.c +3 -5
index 0116c10..a6dc18e 100644
@@ -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.
 		 */