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] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 25 Apr 2007 18:06:45 +0200
From:	Ingo Oeser <netdev@...eo.de>
To:	"John W. Linville" <linville@...driver.com>
Cc:	davem@...emloft.net, linux-wireless@...r.kernel.org,
	netdev@...r.kernel.org, johannes@...solutions.net
Subject: Re: [PATCH] cfg80211: new wireless config infrastructure

Hi there,

John W. Linville schrieb:
> From: Johannes Berg <johannes@...solutions.net>
> --- /dev/null
> +++ b/net/wireless/core.c
> @@ -0,0 +1,209 @@
> +/*
> + * This is the linux wireless configuration interface.
> + *
> + * Copyright 2006, 2007		Johannes Berg <johannes@...solutions.net>
> + */
> +
> +#include <linux/if.h>
> +#include <linux/module.h>
> +#include <linux/err.h>
> +#include <linux/mutex.h>
> +#include <linux/list.h>
> +#include <linux/nl80211.h>
> +#include <linux/debugfs.h>
> +#include <linux/notifier.h>
> +#include <linux/device.h>
> +#include <net/genetlink.h>
> +#include <net/cfg80211.h>
> +#include <net/wireless.h>
> +#include "core.h"
> +#include "sysfs.h"
> +
> +/* name for sysfs, %d is appended */
> +#define PHY_NAME "phy"
> +
> +MODULE_AUTHOR("Johannes Berg");
> +MODULE_LICENSE("GPL");
> +MODULE_DESCRIPTION("wireless configuration support");
> +
> +/* RCU might be appropriate here since we usually
> + * only read the list, and that can happen quite
> + * often because we need to do it for each command */
> +LIST_HEAD(cfg80211_drv_list);
> +DEFINE_MUTEX(cfg80211_drv_mutex);
> +static int wiphy_counter;
> +
> +/* for debugfs */
> +static struct dentry *ieee80211_debugfs_dir;
> +
> +/* exported functions */
> +
> +struct wiphy *wiphy_new(struct cfg80211_ops *ops, int sizeof_priv)
> +{
> +	struct cfg80211_registered_device *drv;
> +	int alloc_size;
> +
> +	alloc_size = sizeof(*drv) + sizeof_priv;
> +
> +	drv = kzalloc(alloc_size, GFP_KERNEL);
> +	if (!drv)
> +		return NULL;
> +
> +	drv->ops = ops;
> +
> +	mutex_lock(&cfg80211_drv_mutex);
> +
> +	if (unlikely(wiphy_counter<0)) {

		mutex_unlock(&cfg80211_drv_mutex);

> +		/* ugh, wrapped! */
> +		kfree(drv);
> +		return NULL;
> +	}
> +	drv->idx = wiphy_counter;
> +
> +	/* give it a proper name */
> +	snprintf(drv->wiphy.dev.bus_id, BUS_ID_SIZE,
> +		 PHY_NAME "%d", drv->idx);
> +
> +	/* now increase counter for the next time */
> +	wiphy_counter++;
> +	mutex_unlock(&cfg80211_drv_mutex);

Since drv and its contents are not visible to anyone yet, 
I suggest the following code flow for that:

mutex_lock(&cfg80211_drv_mutex);

drv->idx = wiphy_counter;

/* increase counter for the next time, if id didn't wrap */
if (drv->idx >= 0)
	wiphy_counter++;

mutex_unlock(&cfg80211_drv_mutex);

if (drv->idx < 0) {
	kfree(drv);
	return NULL;
}

/* give it a proper name */
snprintf(drv->wiphy.dev.bus_id, BUS_ID_SIZE,
	 PHY_NAME "%d", drv->idx);

[enqueue to all lists here]


Rest looks good so far.

Regards

Ingo Oeser
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ