Skip to contentSkip to conversation

staging: slicoss.ko: slicoss.c: Fixed incorrect argument type

PATCH In review Ryan Swan 3 participants 3 messages Oct 18, 2016 – Oct 19, 2016 Staging

lore
Share & tools
lore

Ryan Swan

author
#0 lore raw

PATCH 1/1 staging: slicoss.ko: slicoss.c: Fixed incorrect argument type

sparse produced
warning: incorrect type in argument 2 (different address spaces) expected void const volatile [noderef] <asn:2>*src
got struct slic_stats *stats

casting argument 2 to what is expected by memcpy_fromio() fixed this

---
 drivers/staging/slicoss/slicoss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/slicoss/slicoss.c +1 -1
index 2802b90..7c6feb1 100644
@@ -1057,7 +1057,7 @@ static void slic_upr_request_complete(struct adapter *adapter, u32 isr)
 		if (stats->rcv_drops > old->rcv_drops)
 			adapter->rcv_drops += (stats->rcv_drops -
 					       old->rcv_drops);
-		memcpy_fromio(old, stats, sizeof(*stats));
+		memcpy_fromio(old, (void __iomem *)stats, sizeof(*stats));
 		break;
 	}
 	case SLIC_UPR_RLSR:
Signature · 1 line
2.7.4
#1 lore raw

Hi Ryan,

Quoted 18 lines · Ryan Swan

sparse produced
warning: incorrect type in argument 2 (different address spaces) expected void const volatile [noderef] <asn:2>*src
got struct slic_stats *stats

casting argument 2 to what is expected by memcpy_fromio() fixed this

---
 drivers/staging/slicoss/slicoss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/slicoss/slicoss.c +0 -0
index 2802b90..7c6feb1 100644

drivers/staging/slicoss/slicoss.c static void slic_upr_request_complete(struct adapter *adapter, u32 isr) · line 1063

Quoted 8 lines
drivers/staging/slicoss/slicoss.c +1 -1
@@ -1057,7 +1057,7 @@ static void slic_upr_request_complete(struct adapter *adapter, u32 isr)
 		if (stats->rcv_drops > old->rcv_drops)
 			adapter->rcv_drops += (stats->rcv_drops -
 					       old->rcv_drops);
-		memcpy_fromio(old, stats, sizeof(*stats));
+		memcpy_fromio(old, (void __iomem *)stats, sizeof(*stats));
 		break;
 	}
 	case SLIC_UPR_RLSR:

The issue here is the use of memcpy_fromio() while it actually is not io but dma memory that we copy from.

Regards,
Lino

#2 lore raw
In reply to Ryan Swan
Quoted 17 lines · Ryan Swan

sparse produced
warning: incorrect type in argument 2 (different address spaces) expected void const volatile [noderef] <asn:2>*src
got struct slic_stats *stats

casting argument 2 to what is expected by memcpy_fromio() fixed this

---
 drivers/staging/slicoss/slicoss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/slicoss/slicoss.c +0 -0
index 2802b90..7c6feb1 100644

drivers/staging/slicoss/slicoss.c static void slic_upr_request_complete(struct adapter *adapter, u32 isr) · line 1060

Quoted 5 lines
drivers/staging/slicoss/slicoss.c +1 -1
@@ -1057,7 +1057,7 @@ static void slic_upr_request_complete(struct adapter *adapter, u32 isr)
 		if (stats->rcv_drops > old->rcv_drops)
 			adapter->rcv_drops += (stats->rcv_drops -
 					       old->rcv_drops);
-		memcpy_fromio(old, stats, sizeof(*stats));
+		memcpy_fromio(old, (void __iomem *)stats, sizeof(*stats));

This should probably just be memcpy(). Introduced in commit fdb777751278 ("staging: slicoss: improve implementation concerning the shared memory").

regards,
dan carpenter