From patchwork Thu Dec 8 08:31:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavrilov Ilia X-Patchwork-Id: 31205 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp75268wrr; Thu, 8 Dec 2022 00:38:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf6vppp8olDfqZhHvf8sI4k0sf1zPYkufYMJ6/zTL6YCKbzcVwP1EcHU0qo2QolQHmaXnVuo X-Received: by 2002:a17:906:a18c:b0:7ad:9629:fb96 with SMTP id s12-20020a170906a18c00b007ad9629fb96mr31572936ejy.751.1670488709094; Thu, 08 Dec 2022 00:38:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670488709; cv=none; d=google.com; s=arc-20160816; b=pAhf/1UMwd5d6XyuaECYwgPLG1wpFwyuw0dEuwhLEp2tOrrxrLQ+Sp5ITNE/Qpm6Ul EKEZOzn7UcCJ8BoIucSxWgYw0NgbR/scpE60c/dAx59AYtlEi7HEBxWOifUiiQBN2H7i Dd9P6RSpX5kSsFSBnGQOb7icU+VwOVUzeMrnmhRCJsTxz4lCJXMGfNUsuTZu/CeVj/It l5W2fbJ8ER2aYWWFDuoMS5NDrtR0uxpUB4jhwhSR8QQSXdfNS7WZBThc4a26Y3mozmyW YvgmHRGsM6YNpFD/xEdkf5QLccEDZ//kuXf8EcRI8aNOLSQtWRELpnR33sc1sOh4NSO0 ASHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature:dkim-filter; bh=s0kXhZ5QwF8NQVrywWavoH3BbIaBSkcol4p+WMzzHbA=; b=0JP7V1oXL2DSIPIaTO7PDEUY/jXXMrV28lUcxI9eXihEKUopAggtfvvuVsjqfGlkAq cX9eYm/oJ+epXNQhk/vSYBs2PkK7vI+gMPyh9yyAeWiiTLhT6ZRFS0Z5Ip1tJhc+NuGT /eFVUx3fn2BAg3llnTbCbZsVkH/Z7v2S2FHPJhieV51V2cWesJlNWm1Ov2GBKVSB+s3U rozjXfLrKUkW1BIXXGk6D92NVpABKVMcOUyd/crUNef+3rRIQbGIT5mT2broxGCaHzb7 nEN8+p54/RxhhzM9G7aXM6b4UGfnc9s3+YVvRfSdWt68/qc3JGyq/fKQ5cmU5z2fein5 2vBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infotecs.ru header.s=mx header.b=DbUNE3JG; 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=pass (p=REJECT sp=NONE dis=NONE) header.from=infotecs.ru Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hs37-20020a1709073ea500b007c10ac7f845si6751937ejc.710.2022.12.08.00.38.05; Thu, 08 Dec 2022 00:38:29 -0800 (PST) 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; dkim=pass header.i=@infotecs.ru header.s=mx header.b=DbUNE3JG; 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=pass (p=REJECT sp=NONE dis=NONE) header.from=infotecs.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229878AbiLHIbr (ORCPT + 99 others); Thu, 8 Dec 2022 03:31:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229589AbiLHIbp (ORCPT ); Thu, 8 Dec 2022 03:31:45 -0500 X-Greylist: delayed 278 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 08 Dec 2022 00:31:41 PST Received: from mx0.infotecs.ru (mx0.infotecs.ru [91.244.183.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC32D5E9E1; Thu, 8 Dec 2022 00:31:41 -0800 (PST) Received: from mx0.infotecs-nt (localhost [127.0.0.1]) by mx0.infotecs.ru (Postfix) with ESMTP id 137C21204047; Thu, 8 Dec 2022 11:31:40 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx0.infotecs.ru 137C21204047 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=infotecs.ru; s=mx; t=1670488300; bh=s0kXhZ5QwF8NQVrywWavoH3BbIaBSkcol4p+WMzzHbA=; h=From:To:CC:Subject:Date:From; b=DbUNE3JG4rJX3rTSn9rY81FAixTQREYeC3GYoLlJZ9uBXiqks7lvmdk1JBo5OP4HM DMHChPDRv7l+rQ24/9o8pXnZ4zK+syjvkfjphYp1Pmaf6SoxsLyMXCrJTST9Jgxzt5 5zdfN4WzxfCj2W3iZuqBocCXtD3qwZz31/QDYPS8= Received: from msk-exch-02.infotecs-nt (msk-exch-02.infotecs-nt [10.0.7.192]) by mx0.infotecs-nt (Postfix) with ESMTP id 104FC3005EC0; Thu, 8 Dec 2022 11:31:40 +0300 (MSK) Received: from msk-exch-01.infotecs-nt (10.17.0.3) by msk-exch-02.infotecs-nt (10.17.0.2) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.12; Thu, 8 Dec 2022 11:31:39 +0300 Received: from msk-exch-01.infotecs-nt ([fe80::89df:c35f:46be:fd07]) by msk-exch-01.infotecs-nt ([fe80::89df:c35f:46be:fd07%14]) with mapi id 15.02.1118.012; Thu, 8 Dec 2022 11:31:39 +0300 From: Gavrilov Ilia To: Jiri Pirko CC: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH] net: devlink: Add missing error check to devlink_resource_put() Thread-Topic: [PATCH] net: devlink: Add missing error check to devlink_resource_put() Thread-Index: AQHZCt9+6LuahvuDWEOcrRsPGlrGSw== Date: Thu, 8 Dec 2022 08:31:39 +0000 Message-ID: <20221208082821.3927937-1-Ilia.Gavrilov@infotecs.ru> Accept-Language: ru-RU, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.17.0.10] x-exclaimer-md-config: 208ac3cd-1ed4-4982-a353-bdefac89ac0a MIME-Version: 1.0 X-KLMS-Rule-ID: 1 X-KLMS-Message-Action: clean X-KLMS-AntiSpam-Lua-Profiles: 174026 [Dec 08 2022] X-KLMS-AntiSpam-Version: 5.9.59.0 X-KLMS-AntiSpam-Envelope-From: Ilia.Gavrilov@infotecs.ru X-KLMS-AntiSpam-Rate: 0 X-KLMS-AntiSpam-Status: not_detected X-KLMS-AntiSpam-Method: none X-KLMS-AntiSpam-Auth: dkim=none X-KLMS-AntiSpam-Info: LuaCore: 502 502 69dee8ef46717dd3cb3eeb129cb7cc8dab9e30f6, {Tracking_from_domain_doesnt_match_to}, infotecs.ru:7.1.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;127.0.0.199:7.1.2 X-MS-Exchange-Organization-SCL: -1 X-KLMS-AntiSpam-Interceptor-Info: scan successful X-KLMS-AntiPhishing: Clean, bases: 2022/12/08 05:05:00 X-KLMS-AntiVirus: Kaspersky Security for Linux Mail Server, version 8.0.3.30, bases: 2022/12/08 05:14:00 #20660675 X-KLMS-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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?1751634368398032057?= X-GMAIL-MSGID: =?utf-8?q?1751634368398032057?= When the resource size changes, the return value of the 'nla_put_u64_64bit' function is not checked. That has been fixed to avoid rechecking at the next step. Found by InfoTeCS on behalf of Linux Verification Center (linuxtesting.org) with SVACE. Fixes: d9f9b9a4d05f ("devlink: Add support for resource abstraction") Signed-off-by: Ilia.Gavrilov --- net/core/devlink.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net/core/devlink.c b/net/core/devlink.c index 89baa7c0938b..ff078bcef9ba 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -4193,9 +4193,10 @@ static int devlink_resource_put(struct devlink *devlink, struct sk_buff *skb, nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_ID, resource->id, DEVLINK_ATTR_PAD)) goto nla_put_failure; - if (resource->size != resource->size_new) - nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_SIZE_NEW, - resource->size_new, DEVLINK_ATTR_PAD); + if (resource->size != resource->size_new && + nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_SIZE_NEW, + resource->size_new, DEVLINK_ATTR_PAD)) + goto nla_put_failure; if (devlink_resource_occ_put(resource, skb)) goto nla_put_failure; if (devlink_resource_size_params_put(resource, skb))