aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ieee802154/adf7242.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2022-08-23ieee802154/adf7242: defer destroy_workqueue callLin Ma1-1/+2
There is a possible race condition (use-after-free) like below (FREE) | (USE) adf7242_remove | adf7242_channel cancel_delayed_work_sync | destroy_workqueue (1) | adf7242_cmd_rx | mod_delayed_work (2) | The root cause for this race is that the upper layer (ieee802154) is unaware of this detaching event and the function adf7242_channel can be called without any checks. To fix this, we can add a flag write at the beginning of adf7242_remove and add flag check in adf7242_channel. Or we can just defer the destructive operation like other commit 3e0588c291d6 ("hamradio: defer ax25 kfree after unregister_netdev") which let the ieee802154_unregister_hw() to handle the synchronization. This patch takes the second option. Fixes: 58e9683d1475 ("net: ieee802154: adf7242: Fix OCL calibration runs") Signed-off-by: Lin Ma <linma@zju.edu.cn> Acked-by: Michael Hennerich <michael.hennerich@analog.com> Link: https://lore.kernel.org/r/20220808034224.12642-1-linma@zju.edu.cn Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
2022-02-09spi: make remove callback a void functionUwe Kleine-König1-3/+1
The value returned by an spi driver's remove function is mostly ignored. (Only an error message is printed if the value is non-zero that the error is ignored.) So change the prototype of the remove function to return no value. This way driver authors are not tempted to assume that passing an error to the upper layer is a good idea. All drivers are adapted accordingly. There is no intended change of behaviour, all callbacks were prepared to return 0 before. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Acked-by: Marc Kleine-Budde <mkl@pengutronix.de> Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Jérôme Pouiller <jerome.pouiller@silabs.com> Acked-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Acked-by: Claudius Heine <ch@denx.de> Acked-by: Stefan Schmidt <stefan@datenfreihafen.org> Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Acked-by: Ulf Hansson <ulf.hansson@linaro.org> # For MMC Acked-by: Marcus Folkesson <marcus.folkesson@gmail.com> Acked-by: Łukasz Stelmach <l.stelmach@samsung.com> Acked-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20220123175201.34839-6-u.kleine-koenig@pengutronix.de Signed-off-by: Mark Brown <broonie@kernel.org>
2020-08-03ieee802154/adf7242: check status of adf7242_read_regTom Rix1-1/+3
Clang static analysis reports this error adf7242.c:887:6: warning: Assigned value is garbage or undefined len = len_u8; ^ ~~~~~~ len_u8 is set in adf7242_read_reg(lp, 0, &len_u8); When this call fails, len_u8 is not set. So check the return code. Fixes: 7302b9d90117 ("ieee802154/adf7242: Driver for ADF7242 MAC IEEE802154") Signed-off-by: Tom Rix <trix@redhat.com> Acked-by: Michael Hennerich <michael.hennerich@analog.com> Link: https://lore.kernel.org/r/20200802142339.21091-1-trix@redhat.com Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
2020-07-20net: ieee802154: adf7242: Replace HTTP links with HTTPS onesAlexander A. Klimov1-1/+1
Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Deterministic algorithm: For each file: If not .svg: For each line: If doesn't contain `\bxmlns\b`: For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`: If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`: If both the HTTP and HTTPS versions return 200 OK and serve the same content: Replace HTTP with HTTPS. Signed-off-by: Alexander A. Klimov <grandmaster@al2klimov.de> Link: https://lore.kernel.org/r/20200719113142.58304-1-grandmaster@al2klimov.de Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
2020-07-17ieee802154: fix one possible memleak in adf7242_probeLiu Jian1-1/+3
When probe fail, we should destroy the workqueue. Fixes: 2795e8c25161 ("net: ieee802154: fix a potential NULL pointer dereference") Signed-off-by: Liu Jian <liujian56@huawei.com> Acked-by: Michael Hennerich <michael.hennerich@analog.com> Link: https://lore.kernel.org/r/20200717090121.2143-1-liujian56@huawei.com Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
2019-08-10ieee802154: no need to check return value of debugfs_create functionsGreg Kroah-Hartman1-10/+3
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this. Cc: Alexander Aring <alex.aring@gmail.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: Harry Morris <h.morris@cascoda.com> Cc: linux-wpan@vger.kernel.org Cc: netdev@vger.kernel.org Acked-by: Stefan Schmidt <stefan@datenfreihafen.org> Acked-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2019-05-30treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 149Thomas Gleixner1-2/+1
Based on 1 normalized pattern(s): licensed under the gpl 2 or later extracted by the scancode license scanner the SPDX license identifier GPL-2.0-or-later has been chosen to replace the boilerplate/reference in 82 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Reviewed-by: Richard Fontana <rfontana@redhat.com> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190524100845.150836982@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-03-13net: ieee802154: fix a potential NULL pointer dereferenceKangjie Lu1-0/+4
In case alloc_ordered_workqueue fails, the fix releases sources and returns -ENOMEM to avoid NULL pointer dereference. Signed-off-by: Kangjie Lu <kjlu@umn.edu> Acked-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
2018-09-21ieee802154: remove unecessary condition check before debugfs_remove_recursivezhong jiang1-2/+1
debugfs_remove_recursive has taken IS_ERR_OR_NULL into account. So just remove the condition check before debugfs_remove_recursive. Signed-off-by: zhong jiang <zhongjiang@huawei.com> Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
2018-07-09net: ieee802154: adf7242: Fix OCL calibration runsMichael Hennerich1-1/+28
Reissuing RC_RX every 400ms - to adjust for offset drift in receiver see datasheet page 61, OCL section. Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
2018-07-09net: ieee802154: adf7242: Fix erroneous RX enableMichael Hennerich1-1/+4
Only enable RX mode if the netdev is opened. Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
2017-11-29net: ieee802154: adf7242: Rework IRQ and packet handlingMichael Hennerich1-15/+39
* Stop unconditionally polling for RC_STATUS_PHY_RDY at the entry of the threaded IRQ handler. Once IRQ_RX_PKT_RCVD is received we can read immediately the packet from the buffer. However we still need to wait afterwards for RC_STATUS_PHY_RDY, to make sure that the ACK (in case requested) was processed and send out by the Radio Controller, before we issue the next CMD_RC_RX. This significantly reduces the overall time spend in the threaded IRQ handler. * Avoid raise condition between xmit and coincident packet reception, by disabling the IRQ and clearing the IRQ status upon xmit entry. * Introduce helper functions adf7242_clear_irqstat() and adf7242_cmd_rx() Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com>
2017-11-29net: ieee802154: adf7242: Avoid redundant RC_READY pollingMichael Hennerich1-6/+12
READ/WRITE register and packet buffer can be done anytime as long as SPI_READY. Only CMD transactions require RC_READY && SPI_READY. Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com>
2017-11-29net: ieee802154: adf7242: Add additional DEBUG informationMichael Hennerich1-2/+8
This adds missing status bits and improves the DEBUG prints. Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com>
2017-11-29net: ieee802154: adf7242: Fix bug if defined DEBUGMichael Hennerich1-2/+2
This fixes undefined reference to struct adf7242_local *lp in case DEBUG is defined. Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com>
2017-11-29net: ieee802154: adf7242: Add support for ADF7241 devicesMichael Hennerich1-1/+3
This adds support for ADF7241 Low Power IEEE 802.15.4 Zero-IF 2.4 GHz Transceivers Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com>
2017-11-06ieee802154: adf7242: use unsigned int over only unsignedStefan Schmidt1-4/+4
Bring it in line with the rest of the ieee802154 drivers. Found by checkpatch. Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com> Acked-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com>
2016-11-26Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/netDavid S. Miller1-1/+0
udplite conflict is resolved by taking what 'net-next' did which removed the backlog receive method assignment, since it is no longer necessary. Two entries were added to the non-priv ethtool operations switch statement, one in 'net' and one in 'net-next, so simple overlapping changes. Signed-off-by: David S. Miller <davem@davemloft.net>
2016-11-25net: ieee802154: drop duplicate header delay.hGeliang Tang1-1/+0
Drop duplicate header delay.h from adf7242.c. Signed-off-by: Geliang Tang <geliangtang@gmail.com> Acked-by: Stefan Schmidt <stefan@osg.samsung.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-11-21net: ieee802154: constify ieee802154_ops structuresBhumika Goyal1-1/+1
Declare the structure ieee802154_ops as const as it is only passed as an argument to the function ieee802154_alloc_hw. This argument is of type const struct ieee802154_ops *, so ieee80254_ops structures having this property can be declared as const. Done using Coccinelle: @r1 disable optional_qualifier @ identifier i; position p; @@ static struct ieee802154_ops i@p = {...}; @ok1@ identifier r1.i; position p; expression e1; @@ ieee802154_alloc_hw(e1,&i@p) @bad@ position p!={r1.p,ok1.p}; identifier r1.i; @@ i@p @depends on !bad disable optional_qualifier@ identifier r1.i; @@ static +const struct ieee802154_ops i={...}; @depends on !bad disable optional_qualifier@ identifier r1.i; @@ +const struct ieee802154_ops i; The before and after size details of the affected files are: text data bss dec hex filename 8669 1176 16 9861 2685 drivers/net/ieee802154/adf7242.o 8805 1048 16 9869 268d drivers/net/ieee802154/adf7242.o text data bss dec hex filename 7211 2296 32 9539 2543 drivers/net/ieee802154/atusb.o 7339 2160 32 9531 253b drivers/net/ieee802154/atusb.o Signed-off-by: Bhumika Goyal <bhumirks@gmail.com> Acked-by: Stefan Schmidt <stefan@osg.samsung.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-05-19net: ieee802154/adf7242: syntax error ifdef DEBUGxypron.glpk@gmx.de1-1/+0
If DEBUG is defined, a superfluous closing brace is introduced. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Acked-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-04-08ieee802154/adf7242: fix memory leak of firmwareSudip Mukherjee1-0/+2
If the firmware upload or the firmware verification fails then we printed the error message and exited but we missed releasing the firmware. Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk> Acked-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2015-12-11ieee802154/adf7242: Driver for ADF7242 MAC IEEE802154Michael Hennerich1-0/+1285
This driver has been sitting in the linux-zigbee[2] repository for a long time. We updated it from time to time and made it available via our github kernel repository. The Linux MAC802.15.4 support has improved a lot since then. Thanks to all! So it’s finally time to upstream this driver. The ADF7242 requires an add-on firmware for the automatic IEEE 802.15.4 operating modes. The firmware file is currently made available on the ADF7242 wiki page here [1] [1] http://wiki.analog.com/resources/tools-software/linux-drivers/networking-mac802154/adf7242 [2] http://sourceforge.net/p/linux-zigbee/kernel/ci/devel/tree/drivers/ieee802154/adf7242.c Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>