All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: rtllib_crypt_tkip: Replase printk() with pr_debug()
@ 2015-03-29  0:51 Ioana Ciornei
  2015-04-01 15:33 ` [Outreachy kernel] " Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Ioana Ciornei @ 2015-03-29  0:51 UTC (permalink / raw)
  To: outreachy-kernel; +Cc: 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. 

Signed-off-by: Ioana Ciornei <ciorneiioana@gmail.com>
---
 drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 39 ++++++++++------------------
 1 file changed, 13 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
index ccf8530..1c4025f 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
@@ -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);
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Outreachy kernel] [PATCH] staging: rtllib_crypt_tkip: Replase printk() with pr_debug()
  2015-03-29  0:51 [PATCH] staging: rtllib_crypt_tkip: Replase printk() with pr_debug() Ioana Ciornei
@ 2015-04-01 15:33 ` Greg KH
  2015-04-01 16:19   ` Ioana Ciornei
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2015-04-01 15:33 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: outreachy-kernel

On Sun, Mar 29, 2015 at 02:51:48AM +0200, Ioana Ciornei wrote:
> 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. 
> 
> Signed-off-by: Ioana Ciornei <ciorneiioana@gmail.com>
> ---
>  drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 39 ++++++++++------------------
>  1 file changed, 13 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
> index ccf8530..1c4025f 100644
> --- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
> +++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
> @@ -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);

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Outreachy kernel] [PATCH] staging: rtllib_crypt_tkip: Replase printk() with pr_debug()
  2015-04-01 15:33 ` [Outreachy kernel] " Greg KH
@ 2015-04-01 16:19   ` Ioana Ciornei
  0 siblings, 0 replies; 3+ messages in thread
From: Ioana Ciornei @ 2015-04-01 16:19 UTC (permalink / raw)
  To: Greg KH; +Cc: outreachy-kernel

[-- Attachment #1: Type: text/plain, Size: 3798 bytes --]

On Apr 1, 2015 6:33 PM, "Greg KH" <gregkh@linuxfoundation.org> wrote:
>
> On Sun, Mar 29, 2015 at 02:51:48AM +0200, Ioana Ciornei wrote:
> > 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.
> >
> > Signed-off-by: Ioana Ciornei <ciorneiioana@gmail.com>
> > ---
> >  drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 39
++++++++++------------------
> >  1 file changed, 13 insertions(+), 26 deletions(-)
> >
> > diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
> > index ccf8530..1c4025f 100644
> > --- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
> > +++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
> > @@ -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);
>
> 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

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

Ioana

[-- Attachment #2: Type: text/html, Size: 5285 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-04-01 16:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-29  0:51 [PATCH] staging: rtllib_crypt_tkip: Replase printk() with pr_debug() Ioana Ciornei
2015-04-01 15:33 ` [Outreachy kernel] " Greg KH
2015-04-01 16:19   ` Ioana Ciornei

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.