From patchwork Thu May 11 07:08:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Li X-Patchwork-Id: 92386 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4171104vqo; Thu, 11 May 2023 00:14:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4jqfeu2r0uLQQrukLGwrkFZVmmGxdCa4IxVfnRdfe4vn+0sPmOno7TdqqGz54JsDLb5Czl X-Received: by 2002:a05:6a20:8f08:b0:102:472b:424c with SMTP id b8-20020a056a208f0800b00102472b424cmr7169730pzk.22.1683789299143; Thu, 11 May 2023 00:14:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683789299; cv=none; d=google.com; s=arc-20160816; b=F0Ng8DmPyEG44gV1khyXpmE7R6RJfE9YILigcVfc4LGkucGh2uZGNTIES79xyORFAg 5yaJ/uSzswl6LMXozk/3UC7pQ/VGivxu2IzphHUTuQFWRzQ9mhvQXetXmPzHfBNQHsEX ZrkdHAkIu4BEwdyntoSk+KUdO+jQ3sA4bEPcXjsQPzZE88ebBVFvHCl/vzPGupaaK3Pv fmo9yS3Pwy5lMNCWeGozP6oNKBt+DotEEhY79ifOl0i6yUttU+FnQX2d8eu6rLgMn7AR Rc+c/H7e60Ey+R7nTx+VDV24sOnu/YZZIuGwVu4lgqbM8UBY/p84QqXMNpxsom+E/MTX NZSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=4bzKp+THpOOCKzsHSI23EWbnNIXAtHibPslrpmT07qw=; b=ZbEYiqytzn9e1VtZK/NihKyQkT7UdplXDLaezbRly374lP5SL5RnIMCb/i3jOk2UK/ RU0aqQxhkcYVjJDzahi4AZrcFyJQW0K6bagyXi6wIHjpRUNMhehq7p8FsQkhUiZfopMV HzbPHngOCQs1l8eoE7CHk78+R+FP4MGjYRhV03dTRDrjkdEbzLBSJK/w0fLfYrIji+qa ZOdhONtaXCIgKbMBhbQo/KVLKnbZlXPPwVcFaHPfKvMrCI0IQsZNJI+udrWAzzyUu53y cJv/+I2MWFGTQ0AmzF7elX0QYR/l0tMvqOgfPfeCP+btVnWg5GO9HkjS+F+G9SO7wMVp ayBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w8-20020a63f508000000b005183e6198aasi6035342pgh.794.2023.05.11.00.14.46; Thu, 11 May 2023 00:14:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236758AbjEKHJG (ORCPT + 99 others); Thu, 11 May 2023 03:09:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237362AbjEKHId (ORCPT ); Thu, 11 May 2023 03:08:33 -0400 Received: from out30-101.freemail.mail.aliyun.com (out30-101.freemail.mail.aliyun.com [115.124.30.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F8A9EE; Thu, 11 May 2023 00:08:24 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045168;MF=yang.lee@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0ViJa3FM_1683788900; Received: from localhost(mailfrom:yang.lee@linux.alibaba.com fp:SMTPD_---0ViJa3FM_1683788900) by smtp.aliyun-inc.com; Thu, 11 May 2023 15:08:21 +0800 From: Yang Li To: pavel@ucw.cz Cc: lee@kernel.org, linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, Yang Li , Abaci Robot Subject: [PATCH -next] leds: trigger: netdev: NULL check before dev_{put, hold} Date: Thu, 11 May 2023 15:08:20 +0800 Message-Id: <20230511070820.52731-1-yang.lee@linux.alibaba.com> X-Mailer: git-send-email 2.20.1.7.g153144c MIME-Version: 1.0 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765581047963703847?= X-GMAIL-MSGID: =?utf-8?q?1765581047963703847?= 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 warnings: ./drivers/leds/trigger/ledtrig-netdev.c:291:3-10: WARNING: NULL check before dev_{put, hold} functions is not needed. ./drivers/leds/trigger/ledtrig-netdev.c:401:2-9: WARNING: NULL check before dev_{put, hold} functions is not needed. Reported-by: Abaci Robot Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=4929 Signed-off-by: Yang Li --- drivers/leds/trigger/ledtrig-netdev.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/leds/trigger/ledtrig-netdev.c b/drivers/leds/trigger/ledtrig-netdev.c index 305eb543ba84..92de22be5f1c 100644 --- a/drivers/leds/trigger/ledtrig-netdev.c +++ b/drivers/leds/trigger/ledtrig-netdev.c @@ -287,8 +287,7 @@ static int netdev_trig_notify(struct notifier_block *nb, trigger_data->carrier_link_up = netif_carrier_ok(dev); fallthrough; case NETDEV_REGISTER: - if (trigger_data->net_dev) - dev_put(trigger_data->net_dev); + dev_put(trigger_data->net_dev); dev_hold(dev); trigger_data->net_dev = dev; break; @@ -397,8 +396,7 @@ static void netdev_trig_deactivate(struct led_classdev *led_cdev) cancel_delayed_work_sync(&trigger_data->work); - if (trigger_data->net_dev) - dev_put(trigger_data->net_dev); + dev_put(trigger_data->net_dev); kfree(trigger_data); }