From patchwork Thu Apr 14 13:08:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 562606 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5C7FC433EF for ; Thu, 14 Apr 2022 13:15:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243787AbiDNNRz (ORCPT ); Thu, 14 Apr 2022 09:17:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243819AbiDNNRr (ORCPT ); Thu, 14 Apr 2022 09:17:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C83C25C50; Thu, 14 Apr 2022 06:15:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 188AE612DA; Thu, 14 Apr 2022 13:15:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B38FC385A5; Thu, 14 Apr 2022 13:15:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649942121; bh=muxlBW1xDCad3F4eezC0yyiqkmIBXZvIz/L5nWGM2Tc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vq3YWk8hdHKoQumqJ2u0leP00Luuvtp3HiaJRC8VvMU0kFTrM5vCnT8+kwa8rSMiv 7CKo9hq8YhuCtZxomloPVyJ4zCOFowxCSYVN39DBl2wxRq8Jk8p7ZxUIBl7pzvJmo+ Msvi03Z7/oOVgWsd5Z5QDd8Cr3Isaoyd+AQk7nAs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yajun Deng , "David S. Miller" , Pavel Machek Subject: [PATCH 4.19 004/338] netdevice: add the case if dev is NULL Date: Thu, 14 Apr 2022 15:08:27 +0200 Message-Id: <20220414110839.015690473@linuxfoundation.org> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20220414110838.883074566@linuxfoundation.org> References: <20220414110838.883074566@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Yajun Deng commit b37a466837393af72fe8bcb8f1436410f3f173f3 upstream. Add the case if dev is NULL in dev_{put, hold}, so the caller doesn't need to care whether dev is NULL or not. Signed-off-by: Yajun Deng Signed-off-by: David S. Miller Cc: Pavel Machek Signed-off-by: Greg Kroah-Hartman --- include/linux/netdevice.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -3674,7 +3674,8 @@ void netdev_run_todo(void); */ static inline void dev_put(struct net_device *dev) { - this_cpu_dec(*dev->pcpu_refcnt); + if (dev) + this_cpu_dec(*dev->pcpu_refcnt); } /** @@ -3685,7 +3686,8 @@ static inline void dev_put(struct net_de */ static inline void dev_hold(struct net_device *dev) { - this_cpu_inc(*dev->pcpu_refcnt); + if (dev) + this_cpu_inc(*dev->pcpu_refcnt); } /* Carrier loss detection, dial on demand. The functions netif_carrier_on