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]
Message-Id: <1217295498.28682.16.camel@obelisk.thedillows.org>
Date:	Mon, 28 Jul 2008 21:38:18 -0400
From:	David Dillow <dave@...dillows.org>
To:	Jaswinder Singh <jaswinder@...radead.org>
Cc:	LKML <linux-kernel@...r.kernel.org>, becker@...ld.com,
	davidpmclean@...oo.com, Jeff Garzik <jeff@...zik.org>,
	netdev <netdev@...r.kernel.org>,
	David Woodhouse <dwmw2@...radead.org>
Subject: Re: [PATCH] typhoon: use request_firmware

On Mon, 2008-07-28 at 19:24 +0530, Jaswinder Singh wrote:
> Here is patch for typhoon.c :

It's getting better, as it's not obviously broken now.

> +MODULE_FIRMWARE("3com/typhoon.bin");

Minor nit, but perhaps #define the name, so you don't have to keep this
and the string in typhoon_init_firmware() in sync.

> @@ -307,6 +308,9 @@ struct typhoon {
>  	/* unused stuff (future use) */
>  	int			capabilities;
>  	struct transmit_ring 	txHiRing;
> +
> +	/* firmware */
> +	u8			*tp_fw_image;
>  };

Now you keep one copy per NIC, which doubles the memory usage. Just use
static struct firmware *typhoon_fw;

> +static int typhoon_init_firmware(struct typhoon *tp)
> +{
> +	const struct firmware *fw;
> +	const char fw_name[] = "3com/typhoon.bin";

If you use the #define and the global static, you can get rid of the
above. Just use the define in place of fw_name below:

> +	err = request_firmware(&fw, fw_name, &tp->pdev->dev);
> +	if (err) {
> +		printk(KERN_ERR "%s: Failed to load firmware \"%s\"\n",
> +		       tp->name, fw_name);
> +		return err;
> +	}
> +	tp->tp_fw_image = vmalloc(fw->size);
> +	if (!tp->tp_fw_image) {
> +		err = -ENOMEM;
> +		printk(KERN_ERR "%s: \"%s\" Failed %d\n",
> +		       tp->name, fw_name, err);
> +		goto out;
> +	}

Then you can get rid of the double allocation and memcpy. Just put the
call to release_firmware() in typhoon_cleanup().

> @@ -2102,6 +2132,10 @@ typhoon_open(struct net_device *dev)
>  	if(err < 0)
>  		goto out_sleep;
>  
> +	err = typhoon_init_firmware(tp);
> +	if (err)
> +		goto out_irq;
> +

This should move to either typhoon_init() or typhoon_init_one(). Putting
it in typhoon_init() means we waste memory when the module is loaded if
there is no typhoon NIC; putting it in typhoon_init_one() means it needs
protection from threaded probing, should that ever be put back in. Given
that most modern distros don't do probing by blinding loading modules,
typhoon_init() seems a safe bet.

> @@ -2155,6 +2189,9 @@ typhoon_close(struct net_device *dev)

> +	if (tp->tp_fw_image)
> +		vfree(tp->tp_fw_image);
> +

This goes away and is replaced by a release_firmware() in
typhoon_cleanup() if you do the above.

Dave

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ