net: ieee802154: fix missing checks for regmap_update_bits [Linux 5.1]

net: ieee802154: fix missing checks for regmap_update_bits [Linux 5.1]

This Linux kernel change "net: ieee802154: fix missing checks for regmap_update_bits" is included in the Linux 5.1 release. This change is authored by Kangjie Lu <kjlu [at] umn.edu> on Sun Mar 24 18:18:56 2019 -0500. The commit for this change in Linux stable tree is 22e8860 (patch).

net: ieee802154: fix missing checks for regmap_update_bits

regmap_update_bits could fail and deserves a check.

The patch adds the checks and if it fails, returns its error
code upstream.

Signed-off-by: Kangjie Lu <[email protected]>
Reviewed-by: Mukesh Ojha <[email protected]>
Signed-off-by: Stefan Schmidt <[email protected]>

There are 6 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/net/ieee802154/mcr20a.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ieee802154/mcr20a.c b/drivers/net/ieee802154/mcr20a.c
index c589f5a..8bb53ec 100644
--- a/drivers/net/ieee802154/mcr20a.c
+++ b/drivers/net/ieee802154/mcr20a.c
@@ -533,6 +533,8 @@ struct mcr20a_local {
    dev_dbg(printdev(lp), "no slotted operation\n");
    ret = regmap_update_bits(lp->regmap_dar, DAR_PHY_CTRL1,
                 DAR_PHY_CTRL1_SLOTTED, 0x0);
+   if (ret < 0)
+       return ret;

    /* enable irq */
    enable_irq(lp->spi->irq);
@@ -540,11 +542,15 @@ struct mcr20a_local {
    /* Unmask SEQ interrupt */
    ret = regmap_update_bits(lp->regmap_dar, DAR_PHY_CTRL2,
                 DAR_PHY_CTRL2_SEQMSK, 0x0);
+   if (ret < 0)
+       return ret;

    /* Start the RX sequence */
    dev_dbg(printdev(lp), "start the RX sequence\n");
    ret = regmap_update_bits(lp->regmap_dar, DAR_PHY_CTRL1,
                 DAR_PHY_CTRL1_XCVSEQ_MASK, MCR20A_XCVSEQ_RX);
+   if (ret < 0)
+       return ret;

    return 0;
 }

Leave a Reply

Your email address will not be published. Required fields are marked *