Skip to content

Commit

Permalink
wwan: core: Unshadow error code returned by ida_alloc_range()
Browse files Browse the repository at this point in the history
ida_alloc_range() may return other than -ENOMEM error code.
Unshadow it in the wwan_create_port().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
Reviewed-by: Loic Poulain <loic.poulain@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Andy Shevchenko authored and David S. Miller committed Aug 12, 2021
1 parent 7428022 commit 0de6fd5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/net/wwan/wwan_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,8 @@ struct wwan_port *wwan_create_port(struct device *parent,
{
struct wwan_device *wwandev;
struct wwan_port *port;
int minor, err = -ENOMEM;
char namefmt[0x20];
int minor, err;

if (type > WWAN_PORT_MAX || !ops)
return ERR_PTR(-EINVAL);
Expand All @@ -370,11 +370,14 @@ struct wwan_port *wwan_create_port(struct device *parent,

/* A port is exposed as character device, get a minor */
minor = ida_alloc_range(&minors, 0, WWAN_MAX_MINORS - 1, GFP_KERNEL);
if (minor < 0)
if (minor < 0) {
err = minor;
goto error_wwandev_remove;
}

port = kzalloc(sizeof(*port), GFP_KERNEL);
if (!port) {
err = -ENOMEM;
ida_free(&minors, minor);
goto error_wwandev_remove;
}
Expand Down

0 comments on commit 0de6fd5

Please sign in to comment.