lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.20.1709130750040.2354@hadrien>
Date:   Wed, 13 Sep 2017 07:51:49 +0200 (CEST)
From:   Julia Lawall <julia.lawall@...6.fr>
To:     Haneen Mohammed <hamohammed.sa@...il.com>
cc:     outreachy-kernel@...glegroups.com, gregkh@...uxfoundation.org,
        devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org
Subject: Re: [Outreachy kernel] [PATCH] staging: wlan-ng: Replace pr_debug
 with netdev_dbg



On Tue, 12 Sep 2017, Haneen Mohammed wrote:

> This patch replace pr_debug with netdev_dbg when appropriate net_device
> structure is found.
> Issue found using the following Coccinelle script:
>
> @r exists@
> identifier f, s, i;
> position p;
> @@
>
> f(...,struct s *i,...) {
> <+... when != i == NULL
> (
> pr_err@p(...);
> |
> pr_info@p(...);
> |
> pr_debug@p(...);
> )
> ...+>
> }
>
> @rr@
> identifier r.s, fld;
> @@
>
> struct s {
> 	...
> 	struct net_device *fld;
> 	... };
>
> @@
> identifier r.i, r.s, rr.fld;
> position r.p;
> @@
> (
> -pr_err@p
> +netdev_err
> 	(
> + i->fld,
> ...)
> |
> -pr_info@p
> +netdev_info
> 	(
> + i->fld,
> ...)
> |
> -pr_debug@p
> +netdev_dbg
> 	(
> + i->fld,
> ...)
> )
>
> Signed-off-by: Haneen Mohammed <hamohammed.sa@...il.com>

Acked-by: Julia Lawall <julia.lawall@...6.fr>

In each case, you would want to check that the value of the parameter
cannot be NULL.  It's find in this case because every function starts by
accessing a field of wlandev, and the variable is never updated in the
middle of a function.

julia


> ---
>  drivers/staging/wlan-ng/prism2mgmt.c | 78 ++++++++++++++++++++++--------------
>  1 file changed, 47 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/staging/wlan-ng/prism2mgmt.c b/drivers/staging/wlan-ng/prism2mgmt.c
> index c4aa9e7..7207059 100644
> --- a/drivers/staging/wlan-ng/prism2mgmt.c
> +++ b/drivers/staging/wlan-ng/prism2mgmt.c
> @@ -394,8 +394,9 @@ int prism2mgmt_scan_results(struct wlandevice *wlandev, void *msgp)
>  		count = HFA384x_SCANRESULT_MAX;
>
>  	if (req->bssindex.data >= count) {
> -		pr_debug("requested index (%d) out of range (%d)\n",
> -			 req->bssindex.data, count);
> +		netdev_dbg(wlandev->netdev,
> +			   "requested index (%d) out of range (%d)\n",
> +			   req->bssindex.data, count);
>  		result = 2;
>  		req->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
>  		goto exit;
> @@ -684,7 +685,8 @@ int prism2mgmt_start(struct wlandevice *wlandev, void *msgp)
>
>  	goto done;
>  failed:
> -	pr_debug("Failed to set a config option, result=%d\n", result);
> +	netdev_dbg(wlandev->netdev,
> +		   "Failed to set a config option, result=%d\n", result);
>  	msg->resultcode.data = P80211ENUM_resultcode_invalid_parameters;
>
>  done:
> @@ -1120,15 +1122,17 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
>  		/* Disable monitor mode */
>  		result = hfa384x_cmd_monitor(hw, HFA384x_MONITOR_DISABLE);
>  		if (result) {
> -			pr_debug("failed to disable monitor mode, result=%d\n",
> -				 result);
> +			netdev_dbg(wlandev->netdev,
> +				   "failed to disable monitor mode, result=%d\n",
> +				   result);
>  			goto failed;
>  		}
>  		/* Disable port 0 */
>  		result = hfa384x_drvr_disable(hw, 0);
>  		if (result) {
> -			pr_debug
> -			("failed to disable port 0 after sniffing, result=%d\n",
> +			netdev_dbg
> +			(wlandev->netdev,
> +			     "failed to disable port 0 after sniffing, result=%d\n",
>  			     result);
>  			goto failed;
>  		}
> @@ -1140,8 +1144,9 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
>  						  HFA384x_RID_CNFWEPFLAGS,
>  						  hw->presniff_wepflags);
>  		if (result) {
> -			pr_debug
> -			    ("failed to restore wepflags=0x%04x, result=%d\n",
> +			netdev_dbg
> +			    (wlandev->netdev,
> +			     "failed to restore wepflags=0x%04x, result=%d\n",
>  			     hw->presniff_wepflags, result);
>  			goto failed;
>  		}
> @@ -1153,8 +1158,9 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
>  						  HFA384x_RID_CNFPORTTYPE,
>  						  word);
>  			if (result) {
> -				pr_debug
> -				    ("failed to restore porttype, result=%d\n",
> +				netdev_dbg
> +				    (wlandev->netdev,
> +				     "failed to restore porttype, result=%d\n",
>  				     result);
>  				goto failed;
>  			}
> @@ -1162,8 +1168,9 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
>  			/* Enable the port */
>  			result = hfa384x_drvr_enable(hw, 0);
>  			if (result) {
> -				pr_debug("failed to enable port to presniff setting, result=%d\n",
> -					 result);
> +				netdev_dbg(wlandev->netdev,
> +					   "failed to enable port to presniff setting, result=%d\n",
> +					   result);
>  				goto failed;
>  			}
>  		} else {
> @@ -1182,8 +1189,9 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
>  						  HFA384x_RID_CNFPORTTYPE,
>  						  &(hw->presniff_port_type));
>  				if (result) {
> -					pr_debug
> -					("failed to read porttype, result=%d\n",
> +					netdev_dbg
> +					(wlandev->netdev,
> +					     "failed to read porttype, result=%d\n",
>  					     result);
>  					goto failed;
>  				}
> @@ -1192,24 +1200,27 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
>  						  HFA384x_RID_CNFWEPFLAGS,
>  						  &(hw->presniff_wepflags));
>  				if (result) {
> -					pr_debug
> -					("failed to read wepflags, result=%d\n",
> +					netdev_dbg
> +					(wlandev->netdev,
> +					     "failed to read wepflags, result=%d\n",
>  					     result);
>  					goto failed;
>  				}
>  				hfa384x_drvr_stop(hw);
>  				result = hfa384x_drvr_start(hw);
>  				if (result) {
> -					pr_debug("failed to restart the card for sniffing, result=%d\n",
> -						 result);
> +					netdev_dbg(wlandev->netdev,
> +						   "failed to restart the card for sniffing, result=%d\n",
> +						   result);
>  					goto failed;
>  				}
>  			} else {
>  				/* Disable the port */
>  				result = hfa384x_drvr_disable(hw, 0);
>  				if (result) {
> -					pr_debug("failed to enable port for sniffing, result=%d\n",
> -						 result);
> +					netdev_dbg(wlandev->netdev,
> +						   "failed to enable port for sniffing, result=%d\n",
> +						   result);
>  					goto failed;
>  				}
>  			}
> @@ -1225,8 +1236,9 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
>  		hw->sniff_channel = word;
>
>  		if (result) {
> -			pr_debug("failed to set channel %d, result=%d\n",
> -				 word, result);
> +			netdev_dbg(wlandev->netdev,
> +				   "failed to set channel %d, result=%d\n",
> +				   word, result);
>  			goto failed;
>  		}
>
> @@ -1238,8 +1250,9 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
>  						  HFA384x_RID_CNFPORTTYPE,
>  						  word);
>  			if (result) {
> -				pr_debug
> -				    ("failed to set porttype %d, result=%d\n",
> +				netdev_dbg
> +				    (wlandev->netdev,
> +				     "failed to set porttype %d, result=%d\n",
>  				     word, result);
>  				goto failed;
>  			}
> @@ -1257,8 +1270,9 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
>  			}
>
>  			if (result) {
> -				pr_debug
> -				  ("failed to set wepflags=0x%04x, result=%d\n",
> +				netdev_dbg
> +				  (wlandev->netdev,
> +				   "failed to set wepflags=0x%04x, result=%d\n",
>  				   word, result);
>  				goto failed;
>  			}
> @@ -1283,16 +1297,18 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp)
>  		/* Enable the port */
>  		result = hfa384x_drvr_enable(hw, 0);
>  		if (result) {
> -			pr_debug
> -			    ("failed to enable port for sniffing, result=%d\n",
> +			netdev_dbg
> +			    (wlandev->netdev,
> +			     "failed to enable port for sniffing, result=%d\n",
>  			     result);
>  			goto failed;
>  		}
>  		/* Enable monitor mode */
>  		result = hfa384x_cmd_monitor(hw, HFA384x_MONITOR_ENABLE);
>  		if (result) {
> -			pr_debug("failed to enable monitor mode, result=%d\n",
> -				 result);
> +			netdev_dbg(wlandev->netdev,
> +				   "failed to enable monitor mode, result=%d\n",
> +				   result);
>  			goto failed;
>  		}
>
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@...glegroups.com.
> To post to this group, send email to outreachy-kernel@...glegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170913043225.GA9679%40Haneen.
> For more options, visit https://groups.google.com/d/optout.
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ