2019-11-07 06:34:39

by Pan Bian

[permalink] [raw]
Subject: [PATCH v2] nfc: netlink: fix double device reference drop

The function nfc_put_device(dev) is called twice to drop the reference
to dev when there is no associated local llcp. Remove one of them to fix
the bug.

Signed-off-by: Pan Bian <[email protected]>
---
v2: change subject of the patch
---
net/nfc/netlink.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c
index 17e6ca62f1be..afde0d763039 100644
--- a/net/nfc/netlink.c
+++ b/net/nfc/netlink.c
@@ -1099,7 +1099,6 @@ static int nfc_genl_llc_set_params(struct sk_buff *skb, struct genl_info *info)

local = nfc_llcp_find_local(dev);
if (!local) {
- nfc_put_device(dev);
rc = -ENODEV;
goto exit;
}
@@ -1159,7 +1158,6 @@ static int nfc_genl_llc_sdreq(struct sk_buff *skb, struct genl_info *info)

local = nfc_llcp_find_local(dev);
if (!local) {
- nfc_put_device(dev);
rc = -ENODEV;
goto exit;
}
--
2.7.4


2019-11-07 08:21:37

by Johan Hovold

[permalink] [raw]
Subject: Re: [PATCH v2] nfc: netlink: fix double device reference drop

On Thu, Nov 07, 2019 at 02:29:50PM +0800, Pan Bian wrote:
> The function nfc_put_device(dev) is called twice to drop the reference
> to dev when there is no associated local llcp. Remove one of them to fix
> the bug.
>
> Signed-off-by: Pan Bian <[email protected]>
> ---
> v2: change subject of the patch
> ---
> net/nfc/netlink.c | 2 --
> 1 file changed, 2 deletions(-)

Reviewed-by: Johan Hovold <[email protected]>

In the future, please try to track down the commits introducing the bugs
you fix. That will help not only reviewers, but also the stable
maintainers.

In this case you could have added:

Fixes: 52feb444a903 ("NFC: Extend netlink interface for LTO, RW, and MIUX parameters support")
Fixes: d9b8d8e19b07 ("NFC: llcp: Service Name Lookup netlink interface")

> diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c
> index 17e6ca62f1be..afde0d763039 100644
> --- a/net/nfc/netlink.c
> +++ b/net/nfc/netlink.c
> @@ -1099,7 +1099,6 @@ static int nfc_genl_llc_set_params(struct sk_buff *skb, struct genl_info *info)
>
> local = nfc_llcp_find_local(dev);
> if (!local) {
> - nfc_put_device(dev);
> rc = -ENODEV;
> goto exit;
> }
> @@ -1159,7 +1158,6 @@ static int nfc_genl_llc_sdreq(struct sk_buff *skb, struct genl_info *info)
>
> local = nfc_llcp_find_local(dev);
> if (!local) {
> - nfc_put_device(dev);
> rc = -ENODEV;
> goto exit;
> }

Johan

2019-11-07 23:27:38

by David Miller

[permalink] [raw]
Subject: Re: [PATCH v2] nfc: netlink: fix double device reference drop

From: Pan Bian <[email protected]>
Date: Thu, 7 Nov 2019 14:29:50 +0800

> The function nfc_put_device(dev) is called twice to drop the reference
> to dev when there is no associated local llcp. Remove one of them to fix
> the bug.
>
> Signed-off-by: Pan Bian <[email protected]>
> ---
> v2: change subject of the patch

Applied, with Fixes: tags added, and queued up for -stable, thanks.