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: <54B3B555.5010804@pengutronix.de>
Date:	Mon, 12 Jan 2015 12:51:49 +0100
From:	Marc Kleine-Budde <mkl@...gutronix.de>
To:	"Ahmed S. Darwish" <darwish.07@...il.com>
CC:	Olivier Sobrie <olivier@...rie.be>,
	Oliver Hartkopp <socketcan@...tkopp.net>,
	Wolfgang Grandegger <wg@...ndegger.com>,
	"David S. Miller" <davem@...emloft.net>,
	Paul Gortmaker <paul.gortmaker@...driver.com>,
	Linux-CAN <linux-can@...r.kernel.org>,
	netdev <netdev@...r.kernel.org>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v3 4/4] can: kvaser_usb: Add support for the Usbcan-II
 family

On 01/08/2015 04:19 PM, Ahmed S. Darwish wrote:

[...]

>>>  MODULE_DEVICE_TABLE(usb, kvaser_usb_table);
>>> @@ -463,7 +631,18 @@ static int kvaser_usb_get_software_info(struct kvaser_usb *dev)
>>>  	if (err)
>>>  		return err;
>>>  
>>> -	dev->fw_version = le32_to_cpu(msg.u.softinfo.fw_version);
>>> +	switch (dev->family) {
>>> +	case KVASER_LEAF:
>>> +		dev->fw_version = le32_to_cpu(msg.u.leaf.softinfo.fw_version);
>>> +		break;
>>> +	case KVASER_USBCAN:
>>> +		dev->fw_version = le32_to_cpu(msg.u.usbcan.softinfo.fw_version);
>>> +		break;
>>> +	default:
>>> +		dev_err(dev->udev->dev.parent,
>>> +			"Invalid device family (%d)\n", dev->family);
>>> +		return -EINVAL;
>>
>> The default case should not happen. I think you can remove it.

> It's true, it _should_ never happen. But I only add such checks if
> the follow-up code critically depends on a certain `dev->family`
> behavior. So it's kind of a defensive check against any possible
> bug in driver or memory.
> 
> What do you think?

The kernel is full of callback functions, if you have a bit flip there
you're in trouble anyways. A bug in the driver (or other parts of the
kernel) might overwrite the memory of dev->family, but if this happens,
more things will break.

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


Download attachment "signature.asc" of type "application/pgp-signature" (820 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ