netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] can: raw: Remove NULL check before dev_{put, hold}
@ 2023-08-25  6:46 Jiapeng Chong
  2023-08-25  7:49 ` Oliver Hartkopp
  2023-10-04 10:25 ` Marc Kleine-Budde
  0 siblings, 2 replies; 3+ messages in thread
From: Jiapeng Chong @ 2023-08-25  6:46 UTC (permalink / raw)
  To: socketcan
  Cc: mkl, davem, edumazet, kuba, pabeni, linux-can, netdev,
	linux-kernel, Jiapeng Chong, Abaci Robot

The call netdev_{put, hold} of dev_{put, hold} will check NULL, so there
is no need to check before using dev_{put, hold}, remove it to silence
the warning:

./net/can/raw.c:497:2-9: WARNING: NULL check before dev_{put, hold} functions is not needed.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=6231
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 net/can/raw.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/can/raw.c b/net/can/raw.c
index d50c3f3d892f..ff7797c37018 100644
--- a/net/can/raw.c
+++ b/net/can/raw.c
@@ -493,8 +493,7 @@ static int raw_bind(struct socket *sock, struct sockaddr *uaddr, int len)
 
 out_put_dev:
 	/* remove potential reference from dev_get_by_index() */
-	if (dev)
-		dev_put(dev);
+	dev_put(dev);
 out:
 	release_sock(sk);
 	rtnl_unlock();
-- 
2.20.1.7.g153144c


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] can: raw: Remove NULL check before dev_{put, hold}
  2023-08-25  6:46 [PATCH] can: raw: Remove NULL check before dev_{put, hold} Jiapeng Chong
@ 2023-08-25  7:49 ` Oliver Hartkopp
  2023-10-04 10:25 ` Marc Kleine-Budde
  1 sibling, 0 replies; 3+ messages in thread
From: Oliver Hartkopp @ 2023-08-25  7:49 UTC (permalink / raw)
  To: Jiapeng Chong
  Cc: mkl, davem, edumazet, kuba, pabeni, linux-can, netdev,
	linux-kernel, Abaci Robot, Simon Horman

No need to hurry!

This improvement has already been reported by Simon Horman, see this 
discussion:

https://lore.kernel.org/linux-can/20230822200804.GC3523530@kernel.org/

Reported-by: Simon Horman <horms@kernel.org>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>

@Marc Kleine-Budde: Can you please take this patch via can-next tree?

Thanks,
Oliver


On 25.08.23 08:46, Jiapeng Chong wrote:
> The call netdev_{put, hold} of dev_{put, hold} will check NULL, so there
> is no need to check before using dev_{put, hold}, remove it to silence
> the warning:
> 
> ./net/can/raw.c:497:2-9: WARNING: NULL check before dev_{put, hold} functions is not needed.
> 
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=6231
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
>   net/can/raw.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/net/can/raw.c b/net/can/raw.c
> index d50c3f3d892f..ff7797c37018 100644
> --- a/net/can/raw.c
> +++ b/net/can/raw.c
> @@ -493,8 +493,7 @@ static int raw_bind(struct socket *sock, struct sockaddr *uaddr, int len)
>   
>   out_put_dev:
>   	/* remove potential reference from dev_get_by_index() */
> -	if (dev)
> -		dev_put(dev);
> +	dev_put(dev);
>   out:
>   	release_sock(sk);
>   	rtnl_unlock();

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] can: raw: Remove NULL check before dev_{put, hold}
  2023-08-25  6:46 [PATCH] can: raw: Remove NULL check before dev_{put, hold} Jiapeng Chong
  2023-08-25  7:49 ` Oliver Hartkopp
@ 2023-10-04 10:25 ` Marc Kleine-Budde
  1 sibling, 0 replies; 3+ messages in thread
From: Marc Kleine-Budde @ 2023-10-04 10:25 UTC (permalink / raw)
  To: Jiapeng Chong
  Cc: socketcan, davem, edumazet, kuba, pabeni, linux-can, netdev,
	linux-kernel, Abaci Robot

[-- Attachment #1: Type: text/plain, Size: 823 bytes --]

On 25.08.2023 14:46:56, Jiapeng Chong wrote:
> The call netdev_{put, hold} of dev_{put, hold} will check NULL, so there
> is no need to check before using dev_{put, hold}, remove it to silence
> the warning:
> 
> ./net/can/raw.c:497:2-9: WARNING: NULL check before dev_{put, hold} functions is not needed.
> 
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=6231
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>

Applied to linux-can-next/testing.

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-10-04 10:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-25  6:46 [PATCH] can: raw: Remove NULL check before dev_{put, hold} Jiapeng Chong
2023-08-25  7:49 ` Oliver Hartkopp
2023-10-04 10:25 ` Marc Kleine-Budde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).