Skip to contentSkip to conversation

staging: rtllib_crypt_tkip: Replase printk() with pr_debug()

PATCH In review Ioana Ciornei 2 participants 3 messages Mar 29, 2015 – Apr 1, 2015 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: rtllib_crypt_tkip: Replase printk() with pr_debug()

Replace printk(KERN_DEBUG ..) with pr_debug() since it is the preferred way when there is no netdevice or device struct object to pass as argument.

---
 drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 39 ++++++++++------------------
 1 file changed, 13 insertions(+), 26 deletions(-)
drivers/staging/rtl8192e/rtllib_crypt_tkip.c +13 -26
index ccf8530..1c4025f 100644
@@ -66,8 +66,7 @@ static void *rtllib_tkip_init(int key_idx)
 	priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0,
 			CRYPTO_ALG_ASYNC);
 	if (IS_ERR(priv->tx_tfm_arc4)) {
-		printk(KERN_DEBUG
-		       "rtllib_crypt_tkip: could not allocate crypto API arc4\n");
+		pr_debug("rtllib_crypt_tkip: could not allocate crypto API arc4\n");
 		priv->tx_tfm_arc4 = NULL;
 		goto fail;
 	}
@@ -75,8 +74,7 @@ static void *rtllib_tkip_init(int key_idx)
 	priv->tx_tfm_michael = crypto_alloc_hash("michael_mic", 0,
 			CRYPTO_ALG_ASYNC);
 	if (IS_ERR(priv->tx_tfm_michael)) {
-		printk(KERN_DEBUG
-		       "rtllib_crypt_tkip: could not allocate crypto API michael_mic\n");
+		pr_debug("rtllib_crypt_tkip: could not allocate crypto API michael_mic\n");
 		priv->tx_tfm_michael = NULL;
 		goto fail;
 	}
@@ -84,8 +82,7 @@ static void *rtllib_tkip_init(int key_idx)
 	priv->rx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0,
 			CRYPTO_ALG_ASYNC);
 	if (IS_ERR(priv->rx_tfm_arc4)) {
-		printk(KERN_DEBUG
-		       "rtllib_crypt_tkip: could not allocate crypto API arc4\n");
+		pr_debug("rtllib_crypt_tkip: could not allocate crypto API arc4\n");
 		priv->rx_tfm_arc4 = NULL;
 		goto fail;
 	}
@@ -93,8 +90,7 @@ static void *rtllib_tkip_init(int key_idx)
 	priv->rx_tfm_michael = crypto_alloc_hash("michael_mic", 0,
 			CRYPTO_ALG_ASYNC);
 	if (IS_ERR(priv->rx_tfm_michael)) {
-		printk(KERN_DEBUG
-		       "rtllib_crypt_tkip: could not allocate crypto API michael_mic\n");
+		pr_debug("rtllib_crypt_tkip: could not allocate crypto API michael_mic\n");
 		priv->rx_tfm_michael = NULL;
 		goto fail;
 	}
@@ -399,23 +395,20 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 	keyidx = pos[3];
 	if (!(keyidx & (1 << 5))) {
 		if (net_ratelimit()) {
-			printk(KERN_DEBUG
-			       "TKIP: received packet without ExtIV flag from %pM\n",
+			pr_debug("TKIP: received packet without ExtIV flag from %pM\n",
 			       hdr->addr2);
 		}
 		return -2;
 	}
 	keyidx >>= 6;
 	if (tkey->key_idx != keyidx) {
-		printk(KERN_DEBUG
-		       "TKIP: RX tkey->key_idx=%d frame keyidx=%d priv=%p\n",
+		pr_debug("TKIP: RX tkey->key_idx=%d frame keyidx=%d priv=%p\n",
 		       tkey->key_idx, keyidx, priv);
 		return -6;
 	}
 	if (!tkey->key_set) {
 		if (net_ratelimit()) {
-			printk(KERN_DEBUG
-			       "TKIP: received packet from %pM with keyid=%d that does not have a configured key\n",
+			pr_debug("TKIP: received packet from %pM with keyid=%d that does not have a configured key\n",
 			       hdr->addr2, keyidx);
 		}
 		return -3;
@@ -429,8 +422,7 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 		    (iv32 == tkey->rx_iv32 && iv16 <= tkey->rx_iv16)) &&
 		    tkey->initialized) {
 			if (net_ratelimit()) {
-				printk(KERN_DEBUG
-				       "TKIP: replay detected: STA= %pM previous TSC %08x%04x received TSC %08x%04x\n",
+				pr_debug("TKIP: replay detected: STA= %pM previous TSC %08x%04x received TSC %08x%04x\n",
 				       hdr->addr2, tkey->rx_iv32, tkey->rx_iv16,
 				       iv32, iv16);
 			}
@@ -453,8 +445,7 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 		crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16);
 		if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) {
 			if (net_ratelimit()) {
-				printk(KERN_DEBUG
-				       ": TKIP: failed to decrypt received packet from %pM\n",
+				pr_debug(": TKIP: failed to decrypt received packet from %pM\n",
 				       hdr->addr2);
 			}
 			return -7;
@@ -474,8 +465,7 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 				tkey->rx_phase1_done = 0;
 			}
 			if (net_ratelimit()) {
-				printk(KERN_DEBUG
-				       "TKIP: ICV error detected: STA= %pM\n",
+				pr_debug("TKIP: ICV error detected: STA= %pM\n",
 				       hdr->addr2);
 			}
 			tkey->dot11RSNAStatsTKIPICVErrors++;
@@ -560,8 +550,7 @@ static int rtllib_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv)
 	hdr = (struct rtllib_hdr_4addr *) skb->data;
 
 	if (skb_tailroom(skb) < 8 || skb->len < hdr_len) {
-		printk(KERN_DEBUG
-		       "Invalid packet for Michael MIC add (tailroom=%d hdr_len=%d skb->len=%d)\n",
+		pr_debug("Invalid packet for Michael MIC add (tailroom=%d hdr_len=%d skb->len=%d)\n",
 		       skb_tailroom(skb), hdr_len, skb->len);
 		return -1;
 	}
@@ -624,12 +613,10 @@ static int rtllib_michael_mic_verify(struct sk_buff *skb, int keyidx,
 		struct rtllib_hdr_4addr *hdr;
 
 		hdr = (struct rtllib_hdr_4addr *) skb->data;
-		printk(KERN_DEBUG
-		       "%s: Michael MIC verification failed for MSDU from %pM keyidx=%d\n",
+		pr_debug("%s: Michael MIC verification failed for MSDU from %pM keyidx=%d\n",
 		       skb->dev ? skb->dev->name : "N/A", hdr->addr2,
 		       keyidx);
-		printk(KERN_DEBUG "%d\n",
-		       memcmp(mic, skb->data + skb->len - 8, 8) != 0);
+		pr_debug("%d\n", memcmp(mic, skb->data + skb->len - 8, 8) != 0);
 		if (skb->dev) {
 			pr_info("skb->dev != NULL\n");
 			rtllib_michael_mic_failure(skb->dev, hdr, keyidx);
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 53 lines · Ioana Ciornei

Replace printk(KERN_DEBUG ..) with pr_debug() since it is the preferred way when there is no netdevice or device struct object to pass as argument.

---
 drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 39 ++++++++++------------------
 1 file changed, 13 insertions(+), 26 deletions(-)
drivers/staging/rtl8192e/rtllib_crypt_tkip.c +4 -8
index ccf8530..1c4025f 100644
@@ -66,8 +66,7 @@ static void *rtllib_tkip_init(int key_idx)
 	priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0,
 			CRYPTO_ALG_ASYNC);
 	if (IS_ERR(priv->tx_tfm_arc4)) {
-		printk(KERN_DEBUG
-		       "rtllib_crypt_tkip: could not allocate crypto API arc4\n");
+		pr_debug("rtllib_crypt_tkip: could not allocate crypto API arc4\n");
 		priv->tx_tfm_arc4 = NULL;
 		goto fail;
 	}
@@ -75,8 +74,7 @@ static void *rtllib_tkip_init(int key_idx)
 	priv->tx_tfm_michael = crypto_alloc_hash("michael_mic", 0,
 			CRYPTO_ALG_ASYNC);
 	if (IS_ERR(priv->tx_tfm_michael)) {
-		printk(KERN_DEBUG
-		       "rtllib_crypt_tkip: could not allocate crypto API michael_mic\n");
+		pr_debug("rtllib_crypt_tkip: could not allocate crypto API michael_mic\n");
 		priv->tx_tfm_michael = NULL;
 		goto fail;
 	}
@@ -84,8 +82,7 @@ static void *rtllib_tkip_init(int key_idx)
 	priv->rx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0,
 			CRYPTO_ALG_ASYNC);
 	if (IS_ERR(priv->rx_tfm_arc4)) {
-		printk(KERN_DEBUG
-		       "rtllib_crypt_tkip: could not allocate crypto API arc4\n");
+		pr_debug("rtllib_crypt_tkip: could not allocate crypto API arc4\n");
 		priv->rx_tfm_arc4 = NULL;
 		goto fail;
 	}
@@ -93,8 +90,7 @@ static void *rtllib_tkip_init(int key_idx)
 	priv->rx_tfm_michael = crypto_alloc_hash("michael_mic", 0,
 			CRYPTO_ALG_ASYNC);
 	if (IS_ERR(priv->rx_tfm_michael)) {
-		printk(KERN_DEBUG
-		       "rtllib_crypt_tkip: could not allocate crypto API michael_mic\n");
+		pr_debug("rtllib_crypt_tkip: could not allocate crypto API michael_mic\n");
 		priv->rx_tfm_michael = NULL;
 		goto fail;
 	}

drivers/staging/rtl8192e/rtllib_crypt_tkip.c static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) · line 399

Quoted 7 lines
drivers/staging/rtl8192e/rtllib_crypt_tkip.c +1 -2
@@ -399,23 +395,20 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 	keyidx = pos[3];
 	if (!(keyidx & (1 << 5))) {
 		if (net_ratelimit()) {
-			printk(KERN_DEBUG
-			       "TKIP: received packet without ExtIV flag from %pM\n",
+			pr_debug("TKIP: received packet without ExtIV flag from %pM\n",
 			       hdr->addr2);

If you have a skb, then you should be able to find the network device somehow.

For the other places, odds are you can dig and find it as well, otherwise how does the code know what device it is working with?

If you really can't, then the api needs to be fixed to provide it. No network driver should ever do "blind" printk/pr_* calls.

thanks,

greg k-h

#2 lore raw
Quoted 3 lines · Greg KH
Quoted 1 line · Ioana Ciornei

Replace printk(KERN_DEBUG ..) with pr_debug() since it is the preferred

way when there

Quoted 5 lines
Quoted 5 lines

is no netdevice or device struct object to pass as argument.

---
 drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 39

++++++++++------------------

Quoted 3 lines

Review

Quoted 3 lines
 1 file changed, 13 insertions(+), 26 deletions(-)
(quoted diff) +0 -0

b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c

Quoted 9 lines

drivers/staging/rtl8192e/rtllib_crypt_tkip.c static void *rtllib_tkip_init(int key_idx) · line 70

Quoted 9 lines

index ccf8530..1c4025f 100644

drivers/staging/rtl8192e/rtllib_crypt_tkip.c +0 -2
@@ -66,8 +66,7 @@ static void *rtllib_tkip_init(int key_idx)
      priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0,
                      CRYPTO_ALG_ASYNC);
      if (IS_ERR(priv->tx_tfm_arc4)) {
-             printk(KERN_DEBUG
-                    "rtllib_crypt_tkip: could not allocate crypto API

arc4\n");

Quoted 1 line

drivers/staging/rtl8192e/rtllib_crypt_tkip.c static void *rtllib_tkip_init(int key_idx) · line 69

Quoted 1 line
drivers/staging/rtl8192e/rtllib_crypt_tkip.c +1 -0
+             pr_debug("rtllib_crypt_tkip: could not allocate crypto

API arc4\n");

Quoted 9 lines

drivers/staging/rtl8192e/rtllib_crypt_tkip.c static void *rtllib_tkip_init(int key_idx) · line 79

Quoted 9 lines
drivers/staging/rtl8192e/rtllib_crypt_tkip.c +0 -2
              priv->tx_tfm_arc4 = NULL;
              goto fail;
      }
@@ -75,8 +74,7 @@ static void *rtllib_tkip_init(int key_idx)
      priv->tx_tfm_michael = crypto_alloc_hash("michael_mic", 0,
                      CRYPTO_ALG_ASYNC);
      if (IS_ERR(priv->tx_tfm_michael)) {
-             printk(KERN_DEBUG
-                    "rtllib_crypt_tkip: could not allocate crypto API

michael_mic\n");

Quoted 1 line

drivers/staging/rtl8192e/rtllib_crypt_tkip.c static void *rtllib_tkip_init(int key_idx) · line 77

Quoted 1 line
drivers/staging/rtl8192e/rtllib_crypt_tkip.c +1 -0
+             pr_debug("rtllib_crypt_tkip: could not allocate crypto

API michael_mic\n");

Quoted 9 lines

drivers/staging/rtl8192e/rtllib_crypt_tkip.c static void *rtllib_tkip_init(int key_idx) · line 88

Quoted 9 lines
drivers/staging/rtl8192e/rtllib_crypt_tkip.c +0 -2
              priv->tx_tfm_michael = NULL;
              goto fail;
      }
@@ -84,8 +82,7 @@ static void *rtllib_tkip_init(int key_idx)
      priv->rx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0,
                      CRYPTO_ALG_ASYNC);
      if (IS_ERR(priv->rx_tfm_arc4)) {
-             printk(KERN_DEBUG
-                    "rtllib_crypt_tkip: could not allocate crypto API

arc4\n");

Quoted 1 line

drivers/staging/rtl8192e/rtllib_crypt_tkip.c static void *rtllib_tkip_init(int key_idx) · line 85

Quoted 1 line
drivers/staging/rtl8192e/rtllib_crypt_tkip.c +1 -0
+             pr_debug("rtllib_crypt_tkip: could not allocate crypto

API arc4\n");

Quoted 9 lines

drivers/staging/rtl8192e/rtllib_crypt_tkip.c static void *rtllib_tkip_init(int key_idx) · line 97

Quoted 9 lines
drivers/staging/rtl8192e/rtllib_crypt_tkip.c +0 -2
              priv->rx_tfm_arc4 = NULL;
              goto fail;
      }
@@ -93,8 +90,7 @@ static void *rtllib_tkip_init(int key_idx)
      priv->rx_tfm_michael = crypto_alloc_hash("michael_mic", 0,
                      CRYPTO_ALG_ASYNC);
      if (IS_ERR(priv->rx_tfm_michael)) {
-             printk(KERN_DEBUG
-                    "rtllib_crypt_tkip: could not allocate crypto API

michael_mic\n");

Quoted 1 line

drivers/staging/rtl8192e/rtllib_crypt_tkip.c static void *rtllib_tkip_init(int key_idx) · line 93

Quoted 1 line
drivers/staging/rtl8192e/rtllib_crypt_tkip.c +1 -0
+             pr_debug("rtllib_crypt_tkip: could not allocate crypto

API michael_mic\n");

Quoted 4 lines

drivers/staging/rtl8192e/rtllib_crypt_tkip.c static int rtllib_tkip_decrypt(struct sk_buff

Quoted 4 lines
drivers/staging/rtl8192e/rtllib_crypt_tkip.c +0 -0
              priv->rx_tfm_michael = NULL;
              goto fail;
      }
@@ -399,23 +395,20 @@ static int rtllib_tkip_decrypt(struct sk_buff

*skb, int hdr_len, void *priv)

Quoted 5 lines

drivers/staging/rtl8192e/rtllib_crypt_tkip.c static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)

Quoted 5 lines
drivers/staging/rtl8192e/rtllib_crypt_tkip.c +0 -2
      keyidx = pos[3];
      if (!(keyidx & (1 << 5))) {
              if (net_ratelimit()) {
-                     printk(KERN_DEBUG
-                            "TKIP: received packet without ExtIV flag

from %pM\n",

Quoted 1 line

drivers/staging/rtl8192e/rtllib_crypt_tkip.c static int rtllib_tkip_decrypt(struct sk_buff · line 398

Quoted 1 line
drivers/staging/rtl8192e/rtllib_crypt_tkip.c +1 -0
+                     pr_debug("TKIP: received packet without ExtIV

flag from %pM\n",

Quoted 8 lines

drivers/staging/rtl8192e/rtllib_crypt_tkip.c static int rtllib_tkip_decrypt(struct sk_buff · line 399

Quoted 1 line
drivers/staging/rtl8192e/rtllib_crypt_tkip.c +0 -0
                             hdr->addr2);

If you have a skb, then you should be able to find the network device somehow.

For the other places, odds are you can dig and find it as well, otherwise how does the code know what device it is working with?

Quoted 6 lines

If you really can't, then the api needs to be fixed to provide it. No network driver should ever do "blind" printk/pr_* calls.

thanks,

greg k-h

Thanks for the hint.
I wil revise all the patches and send a new patchset.

Ioana