Skip to contentSkip to conversation

b43: Don't use memcpy for overlapping areas

PATCH New Michael Buesch 1 participant 1 message Aug 28, 2008 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 b43: Don't use memcpy for overlapping areas

It is valid to pass &gphy->rfatt and &gphy->bbatt as rfatt and bbatt pointer arguments to the function. So we have to use memmove for the possibly overlapping memory areas.

---

John, since we have new policies for bugfixes and I can't prove that this will actually fix something for somebody in real life, please queue for the next merge window.

drivers/net/wireless/b43/phy_g.c +4 -3
Index: wireless-testing/drivers/net/wireless/b43/phy_g.c
===================================================================
@@ -229,17 +229,18 @@ void b43_set_txpower_g(struct b43_wldev 
 	rf = rfatt->att;
 	tx_bias = lo->tx_bias;
 	tx_magn = lo->tx_magn;
 	if (unlikely(tx_bias == 0xFF))
 		tx_bias = 0;
 
-	/* Save the values for later */
+	/* Save the values for later. Use memmove, because it's valid
+	 * to pass &gphy->rfatt as rfatt pointer argument. Same for bbatt. */
 	gphy->tx_control = tx_control;
-	memcpy(&gphy->rfatt, rfatt, sizeof(*rfatt));
+	memmove(&gphy->rfatt, rfatt, sizeof(*rfatt));
 	gphy->rfatt.with_padmix = !!(tx_control & B43_TXCTL_TXMIX);
-	memcpy(&gphy->bbatt, bbatt, sizeof(*bbatt));
+	memmove(&gphy->bbatt, bbatt, sizeof(*bbatt));
 
 	if (b43_debug(dev, B43_DBG_XMITPOWER)) {
 		b43dbg(dev->wl, "Tuning TX-power to bbatt(%u), "
 		       "rfatt(%u), tx_control(0x%02X), "
 		       "tx_bias(0x%02X), tx_magn(0x%02X)\n",
 		       bb, rf, tx_control, tx_bias, tx_magn);