net: hdlc_x25: Return meaningful error code in x25_open
authorXie He <xie.he.0141@gmail.com>
Wed, 3 Feb 2021 07:15:41 +0000 (23:15 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Feb 2021 10:02:26 +0000 (11:02 +0100)
[ Upstream commit 81b8be68ef8e8915d0cc6cedd2ac425c74a24813 ]

It's not meaningful to pass on LAPB error codes to HDLC code or other
parts of the system, because they will not understand the error codes.

Instead, use system-wide recognizable error codes.

Fixes: f362e5fe0f1f ("wan/hdlc_x25: make lapb params configurable")
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Xie He <xie.he.0141@gmail.com>
Acked-by: Martin Schiller <ms@dev.tdt.de>
Link: https://lore.kernel.org/r/20210203071541.86138-1-xie.he.0141@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wan/hdlc_x25.c

index f52b9fe..34bc53f 100644 (file)
@@ -171,11 +171,11 @@ static int x25_open(struct net_device *dev)
 
        result = lapb_register(dev, &cb);
        if (result != LAPB_OK)
-               return result;
+               return -ENOMEM;
 
        result = lapb_getparms(dev, &params);
        if (result != LAPB_OK)
-               return result;
+               return -EINVAL;
 
        if (state(hdlc)->settings.dce)
                params.mode = params.mode | LAPB_DCE;
@@ -190,7 +190,7 @@ static int x25_open(struct net_device *dev)
 
        result = lapb_setparms(dev, &params);
        if (result != LAPB_OK)
-               return result;
+               return -EINVAL;
 
        return 0;
 }