aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/can/sja1000/peak_pci.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2021-10-17can: peak_pci: peak_pci_remove(): fix UAFZheyu Ma1-5/+4
When remove the module peek_pci, referencing 'chan' again after releasing 'dev' will cause UAF. Fix this by releasing 'dev' later. The following log reveals it: [ 35.961814 ] BUG: KASAN: use-after-free in peak_pci_remove+0x16f/0x270 [peak_pci] [ 35.963414 ] Read of size 8 at addr ffff888136998ee8 by task modprobe/5537 [ 35.965513 ] Call Trace: [ 35.965718 ] dump_stack_lvl+0xa8/0xd1 [ 35.966028 ] print_address_description+0x87/0x3b0 [ 35.966420 ] kasan_report+0x172/0x1c0 [ 35.966725 ] ? peak_pci_remove+0x16f/0x270 [peak_pci] [ 35.967137 ] ? trace_irq_enable_rcuidle+0x10/0x170 [ 35.967529 ] ? peak_pci_remove+0x16f/0x270 [peak_pci] [ 35.967945 ] __asan_report_load8_noabort+0x14/0x20 [ 35.968346 ] peak_pci_remove+0x16f/0x270 [peak_pci] [ 35.968752 ] pci_device_remove+0xa9/0x250 Fixes: e6d9c80b7ca1 ("can: peak_pci: add support of some new PEAK-System PCI cards") Link: https://lore.kernel.org/all/1634192913-15639-1-git-send-email-zheyuma97@gmail.com Cc: stable@vger.kernel.org Signed-off-by: Zheyu Ma <zheyuma97@gmail.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2021-07-25can: peak_pci: Add name and FW version of the card in kernel bufferStephane Grosjean1-11/+53
This patch adds name and (possibly) firmware version information to the kernel about the detected PEAK-System CAN - PCI/PCIe interface card. Link: https://lore.kernel.org/r/20210607151720.13571-1-s.grosjean@peak-system.com Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com> [mkl: reformated struct pci_device_id peak_pci_tbl] Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2021-07-25can: peak_pci: fix checkpatch warningsMarc Kleine-Budde1-2/+4
This patch cleans several checkpatch warnings in the peak_pci driver. Cc: Stephane Grosjean <s.grosjean@peak-system.com> Link: https://lore.kernel.org/r/20210616102811.2449426-0-mkl@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2021-07-25can: peak_pci: convert comments to network style commentsMarc Kleine-Budde1-35/+14
This patch converts all comments to network subsystem style comments. Cc: Stephane Grosjean <s.grosjean@peak-system.com> Link: https://lore.kernel.org/r/20210616102811.2449426-8-mkl@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2021-03-17module: remove never implemented MODULE_SUPPORTED_DEVICELeon Romanovsky1-2/+0
MODULE_SUPPORTED_DEVICE was added in pre-git era and never was implemented. We can safely remove it, because the kernel has grown to have many more reliable mechanisms to determine if device is supported or not. Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-09-21can: drivers: fix spelling mistakesMarc Kleine-Budde1-1/+1
This patch fixes spelling erros found by "codespell" in the drivers/net/can subtree. Link: https://lore.kernel.org/r/20200915223527.1417033-6-mkl@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2019-08-20can: peak_pci: Make structure peak_pciec_i2c_bit_ops constantNishka Dasgupta1-1/+1
Static structure peak_pciec_i2c_bit_ops, of type i2c_algo_bit_data, is not used except to be copied into another variable. Hence make it const to protect it from modification. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2019-06-19treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 495Thomas Gleixner1-9/+1
Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the version 2 of the gnu general public license as published by the free software foundation this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 10 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Enrico Weigelt <info@metux.net> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190604081206.259525894@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-27can: sja1000: Replace mdelay with usleep_range in peak_pci_probeJia-Ju Bai1-1/+1
peak_pci_probe() is never called in atomic context. peak_pci_probe() is set as ".probe" in struct pci_driver. Despite never getting called from atomic context, peak_pci_probe() calls mdelay() to busily wait. This is not necessary and can be replaced with usleep_range() to avoid busy waiting. This is found by a static analysis tool named DCNS written by myself. And I also manually check it. Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2017-12-01can: peak/pci: fix potential bug when probe() failsStephane Grosjean1-1/+4
PCI/PCIe drivers for PEAK-System CAN/CAN-FD interfaces do some access to the PCI config during probing. In case one of these accesses fails, a POSITIVE PCIBIOS_xxx error code is returned back. This POSITIVE error code MUST be converted into a NEGATIVE errno for the probe() function to indicate it failed. Using the pcibios_err_to_errno() function, we make sure that the return code will always be negative. Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com> Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2015-09-30can: peak_pci: add unused device id. in devices tableStephane Grosjean1-0/+1
While new PEAK_PCIE_OEM_ID has been defined since 3.17, no corresponding entry has been added in the peak_pci_tbl[] of the peak_pci CAN driver. This patch enables now users of the PCAN-PCI Express OEM card to run the peak_pci driver too. Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-09-18can: peak_pci: add PCI ID definition pcie card variantOliver Hartkopp1-1/+5
Add PCI ID definition for the single channel PCAN ExpressCard 34 adapter. Due to the subsystem id evaluation the correct number of channels (here 1) is created at initialization time. Tested including the LED functionality. Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net> Acked-by: Stephane Grosjean <s.grosjean@peak-system.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-08-12PCI: Remove DEFINE_PCI_DEVICE_TABLE macro useBenoit Taine1-1/+1
We should prefer `struct pci_device_id` over `DEFINE_PCI_DEVICE_TABLE` to meet kernel coding style guidelines. This issue was reported by checkpatch. A simplified version of the semantic patch that makes this change is as follows (http://coccinelle.lip6.fr/): // <smpl> @@ identifier i; declarer name DEFINE_PCI_DEVICE_TABLE; initializer z; @@ - DEFINE_PCI_DEVICE_TABLE(i) + const struct pci_device_id i[] = z; // </smpl> [bhelgaas: add semantic patch] Signed-off-by: Benoit Taine <benoit.taine@lip6.fr> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
2014-05-21can: peak_pci: prevent use after free at netdev removalStephane Grosjean1-5/+9
As remarked by Christopher R. Baker in his post at http://marc.info/?l=linux-can&m=139707295706465&w=2 there's a possibility for an use after free condition at device removal. This simplified patch introduces an additional variable to prevent the issue. Thanks for catching this. Cc: linux-stable <stable@vger.kernel.org> Reported-by: Christopher R. Baker <cbaker@rec.ri.cmu.edu> Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-03-17can: populate netdev::dev_id for udev discriminationChristopher R. Baker1-0/+1
My objective is to be able to totally discriminate CAN ports on multi-port cards via udev so as to rename them to semantically interesting/unique names for my system (e.g., "ecuCAN" and "auxCAN" instead of "can0" and "can1"). The following patch assigns the dev_id field to match the channel number on all multi-channel devices. I can only test my two-port Peak PCI card, but it works as expected: ATTRS{dev_id} now expresses the port number and my udev rules now unambiguously pick out and rename my individual CAN ports. Signed-off-by: Christopher R. Baker <cbaker@rec.ri.cmu.edu> Tested-by: Oliver Hartkopp <socketcan@hartkopp.net> [PEAK PCAN-USB pro and EMS PCMCIA] Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2013-09-21can: sja1000: remove unnecessary pci_set_drvdata()Jingoo Han1-2/+0
The driver core clears the driver data to NULL after device_release or on probe failure. Thus, it is not needed to manually clear the device driver data to NULL. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2013-04-16can: sja1000: use common prefix for all sja1000 definesOliver Hartkopp1-1/+1
This is a follow up patch to: f901b6b can: sja1000: fix define conflict on SH That patch fixed a define conflict between the SH architecture and the sja1000 driver, by addind a prefix to one macro only. This patch consistently renames the prefix of the SJA1000 controller registers from "REG_" to "SJA1000_". Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2013-02-20Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-nextLinus Torvalds1-4/+1
Pull networking update from David Miller: 1) Checkpoint/restarted TCP sockets now can properly propagate the TCP timestamp offset. From Andrey Vagin. 2) VMWARE VM VSOCK layer, from Andy King. 3) Much improved support for virtual functions and SR-IOV in bnx2x, from Ariel ELior. 4) All protocols on ipv4 and ipv6 are now network namespace aware, and all the compatability checks for initial-namespace-only protocols is removed. Thanks to Tom Parkin for helping deal with the last major holdout, L2TP. 5) IPV6 support in netpoll and network namespace support in pktgen, from Cong Wang. 6) Multiple Registration Protocol (MRP) and Multiple VLAN Registration Protocol (MVRP) support, from David Ward. 7) Compute packet lengths more accurately in the packet scheduler, from Eric Dumazet. 8) Use per-task page fragment allocator in skb_append_datato_frags(), also from Eric Dumazet. 9) Add support for connection tracking labels in netfilter, from Florian Westphal. 10) Fix default multicast group joining on ipv6, and add anti-spoofing checks to 6to4 and 6rd. From Hannes Frederic Sowa. 11) Make ipv4/ipv6 fragmentation memory limits more reasonable in modern times, rearrange inet frag datastructures for better cacheline locality, and move more operations outside of locking. From Jesper Dangaard Brouer. 12) Instead of strict master <--> slave relationships, allow arbitrary scenerios with "upper device lists". From Jiri Pirko. 13) Improve rate limiting accuracy in TBF and act_police, also from Jiri Pirko. 14) Add a BPF filter netfilter match target, from Willem de Bruijn. 15) Orphan and delete a bunch of pre-historic networking drivers from Paul Gortmaker. 16) Add TSO support for GRE tunnels, from Pravin B SHelar. Although this still needs some minor bug fixing before it's %100 correct in all cases. 17) Handle unresolved IPSEC states like ARP, with a resolution packet queue. From Steffen Klassert. 18) Remove TCP Appropriate Byte Count support (ABC), from Stephen Hemminger. This was long overdue. 19) Support SO_REUSEPORT, from Tom Herbert. 20) Allow locking a socket BPF filter, so that it cannot change after a process drops capabilities. 21) Add VLAN filtering to bridge, from Vlad Yasevich. 22) Bring ipv6 on-par with ipv4 and do not cache neighbour entries in the ipv6 routes, from YOSHIFUJI Hideaki. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1538 commits) ipv6: fix race condition regarding dst->expires and dst->from. net: fix a wrong assignment in skb_split() ip_gre: remove an extra dst_release() ppp: set qdisc_tx_busylock to avoid LOCKDEP splat atl1c: restore buffer state net: fix a build failure when !CONFIG_PROC_FS net: ipv4: fix waring -Wunused-variable net: proc: fix build failed when procfs is not configured Revert "xen: netback: remove redundant xenvif_put" net: move procfs code to net/core/net-procfs.c qmi_wwan, cdc-ether: add ADU960S bonding: set sysfs device_type to 'bond' bonding: fix bond_release_all inconsistencies b44: use netdev_alloc_skb_ip_align() xen: netback: remove redundant xenvif_put net: fec: Do a sanity check on the gpio number ip_gre: propogate target device GSO capability to the tunnel device ip_gre: allow CSUM capable devices to handle packets bonding: Fix initialize after use for 3ad machine state spinlock bonding: Fix race condition between bond_enslave() and bond_3ad_update_lacp_rate() ...
2013-02-04can: Remove unnecessary alloc/OOM messagesJoe Perches1-4/+1
alloc failures already get standardized OOM messages and a dump_stack. Signed-off-by: Joe Perches <joe@perches.com> Acked-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
2012-12-28sja1000: don't use [delayed_]work_pending()Tejun Heo1-2/+1
There's no need to test whether a (delayed) work item in pending before queueing, flushing or cancelling it. Most uses are unnecessary and quite a few of them are buggy. Remove unnecessary pending tests from sja1000. Only compile tested. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: "David S. Miller" <davem@davemloft.net> Cc: Wolfgang Grandegger <wg@grandegger.com> Cc: netdev@vger.kernel.org
2012-12-07drivers/net: fix up function prototypes after __dev* removalsGreg Kroah-Hartman1-2/+1
The __dev* removal patches for the network drivers ended up messing up the function prototypes for a bunch of drivers. This patch fixes all of them back up to be properly aligned. Bonus is that this almost removes 100 lines of code, always a nice surprise. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2012-12-03can: remove __dev* attributesBill Pemberton1-3/+3
CONFIG_HOTPLUG is going away as an option. As result the __dev* markings will be going away. Remove use of __devinit, __devexit_p, __devinitdata, __devinitconst, and __devexit. Signed-off-by: Bill Pemberton <wfp5p@virginia.edu> Cc: Wolfgang Grandegger <wg@grandegger.com> Cc: Marc Kleine-Budde <mkl@pengutronix.de> Cc: linux-can@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-10-24can: sja1000: fix/add miniPCIe/cPCI PC/104Plus PCI/104e PEAK-System boardsStephane Grosjean1-2/+11
This patch adds the support for 4 new PCI boards based on the SJA1000 CAN controller, from PEAK-System Technik: . PCAN-miniPCIe (PCI-Express Mini slots, available as single or dual-channel) . PCAN-cPCI (CompactPCI format, available as single or dual-channel) . PCAN-PC/104-Plus (PC/104-Plus system, av. as 1, 2 or 4 channels) . PCAN-PCI/104-Express (PCI/104-Express system, av. as 1 or 2 channels) This patch also fixes a typo in existing "PEAK_MPCI_DEVICE_ID" identifier (missing "e" for Express). Finally, it also changes the author as well as it updates the module supported devices list. Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com> Acked-by: Oliver Hartkopp <socketcan@hartkopp.net> Acked-by: Wolfgang Grandegger <wg@grandegger.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2012-10-04can: peak_pci: fix error return codePeter Senna Tschudin1-0/+2
Convert a nonnegative error return code to a negative one, as returned elsewhere in the function. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> ( if@p1 (\(ret < 0\|ret != 0\)) { ... return ret; } | ret@p1 = 0 ) ... when != ret = e1 when != &ret *if(...) { ... when != ret = e2 when forall return ret; } // </smpl> Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2012-04-16net/can: use module_pci_driverAxel Lin1-11/+1
This patch converts the drivers in drivers/net/can/* to use module_pci_driver() macro which makes the code smaller and a bit simpler. Signed-off-by: Axel Lin <axel.lin@gmail.com> Cc: Wolfgang Grandegger <wg@grandegger.com> Cc: Marc Kleine-Budde <mkl@pengutronix.de> Cc: "David S. Miller" <davem@davemloft.net> Cc: linux-can@vger.kernel.org Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2012-03-03can: peak_pci: add support of some new PEAK-System PCI cardsStephane Grosjean1-14/+491
This patch adds the support of some new PEAK-System PCI cards in the CAN network sub-system. These are: PCAN-PCIeC (PCI-ExpressCard) PCAN-mminiPCI (mini-PCI) PCAN-PCI (PCI next-gen) This patch also adds the control of the blinking leds of the PCAN-PCIeC. Tested-by: Oliver Hartkopp <socketcan@hartkopp.net> Acked-by: Wolfgang Grandegger <wg@grandegger.com> Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2012-02-03can: peak_pci: Fix the way channels are linked togetherStephane Grosjean1-14/+9
Change the way channels objects are linked together by peak_pci_probe() avoiding any kernel oops when driver is removed. Side effect is that the list is now browsed from last to first channel. Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2011-11-21net, sja1000: Don't include version.h in peak_pci.c when not neededJesper Juhl1-1/+0
It was pointed out by "make versioncheck" that we do not need to include version.h in drivers/net/can/sja1000/peak_pci.c This patch removes the unneeded include. Signed-off-by: Jesper Juhl <jj@chaosbits.net> Acked-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
2011-09-21can/sja1000: driver for PEAK PCAN PCI/PCIe cardsWolfgang Grandegger1-0/+291
This patch add the peak_pci driver for the PCAN PCI/PCIe cards (1, 2, 3 or 4 channels) from PEAK Systems (http://www.peak-system.com). Signed-off-by: Wolfgang Grandegger <wg@grandegger.com> Acked-by: Marc Kleine-Budde <mkl@pengutronix.de> Tested-by: Oliver Hartkopp <socketcan@hartkopp.net> Signed-off-by: David S. Miller <davem@davemloft.net>