Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2026471pxm; Thu, 24 Feb 2022 14:38:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJzkQQNUN4FzHreF/DeD5cUpzrn1NwFskKM9qp51l+myHv0jL1BLk7cWMlJEaiJrw1tVTi5n X-Received: by 2002:a17:90a:4811:b0:1bc:c2e3:4568 with SMTP id a17-20020a17090a481100b001bcc2e34568mr243708pjh.223.1645742282941; Thu, 24 Feb 2022 14:38:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645742282; cv=none; d=google.com; s=arc-20160816; b=i/VhGHBz12fWSTEc5Vt7HIE20Hy5wLbvFoxknSsvNcgPpg0FYl4P4epGz0yK1oRKGa ifu9O3TbOpwD90Lk0eSsHji7JlftefPXS+5sBgqkBENaHczw1Tcosn8vP4DIZBwf/kB8 w2hQk0kzEN2nreSusppWMwaoiP0meN/6h0fEI8PpG8eegGoa1jcQtP+EkMWVkk4FpnV3 ORE2lOfpVlwgvVBqBoktcGKKLncon3PrhliWlHQgtO09X6LNwDZhTYmZf3IAyia/+Sub fR2+8rNSYcUw5y9h+5Jyo0Csx2X76U5PcCeiAxngSUFKNh4BSzd2obcGAB705oh+rm51 JYhQ== 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:dkim-signature; bh=23uPqqlxtmnZRHLs9v3vgksA5KeOpFw/ThnhTpkf+2w=; b=a7W498d8Nfk6T1ZIe8k1rqUpRZIr7C9z5wQmrA9alqrmBWqpwc0dJn4Ea5LxzAbhS8 axGA+urzylqleUH3roqDGY4aiWThUK4lY4MaUedYJBpETTUdPSb61bkoCwU8DPq8Hlf1 PzqGTJtbuGoxPsPcPBXphY2PX5xSX0r0jAMCbTcG2jgzQNOYzPUrWRx+sVJlXmRLjQ9w 0OhExSBhJfq4nssIznx4Q/3R6zX53iNoiK1F7jQBuEl8q205DI+mMtCkIYGa8nwsgYF6 JMxgmmeXjtoiw9TM/PuwbkLIXEzr73Gv2Iw+hH8OoAfH8OFqVUD5FOruqHZ+BaeruRBx By6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=S6nCprqx; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c2-20020a637242000000b0036faa41d229si378193pgn.624.2022.02.24.14.37.47; Thu, 24 Feb 2022 14:38:02 -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=@gmail.com header.s=20210112 header.b=S6nCprqx; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235399AbiBXWP7 (ORCPT + 99 others); Thu, 24 Feb 2022 17:15:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235311AbiBXWP5 (ORCPT ); Thu, 24 Feb 2022 17:15:57 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FA2129DD04; Thu, 24 Feb 2022 14:15:27 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id d28so1763113wra.4; Thu, 24 Feb 2022 14:15:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=23uPqqlxtmnZRHLs9v3vgksA5KeOpFw/ThnhTpkf+2w=; b=S6nCprqxh0JglbBAqwKJDoHoVIjtj4T6nsOoxoor9OqZxzcWSmesnc8rh8G+UcJWwk mc13iC3iU8uKZp4mj0CgARdJtp+90Ud9bgn5xxixO3CyqpAeGCn0AN3oF1cX3oJB8QHI 8UDrUzs36GYtOFY6uAjLWQanpjCWTIYlFlqjK+5LUI+xyxfWFQ6tVS0z0hiVKS+6d/0p uDzEg8pnt+wxr4pKPMoXM/zFFnEQk9VlaKv2+C5Vd2mQ7edNv+t4RTkX4Sr9Xtq8hNMz ujeMJtqjfqPyaAiw66xkhG8E57AyVTyOdWffuxDtoxuEQE1wiizAlDyCwHPUFQtj1pHX q82g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=23uPqqlxtmnZRHLs9v3vgksA5KeOpFw/ThnhTpkf+2w=; b=w2hc+VyG5yjyra+NFXy2ClKUEgfH2tdF0yiGVRlyQOkYVDFSHp2xuOLFEwPQozVg8J gttDbdi5tVcMCyRElPVA5hgc2+TO07lv5ecf/E2o/DQs8yYyLdsW/FMZ3UCKQ/diycsz mtxO+r/WNk7wbunAncECtjIK3lxJyQjP4jaCk0n7RYljPXavfd3SUmz45EZlYtDay4UV qUd1T18AwZgljoXNo7emjcXFF18MEcX7WKhMVyiHinpGbUeLPbHK/HBr4T/mzj3Bc0zT BgjiAE6lo4a/tX4dqIuV6GEaCSQ99sD4Vkf59/orkq2mvSXppLBTvhrn0d9nCJmOWPcT qvYg== X-Gm-Message-State: AOAM533Clabvnq1Pcxc8xb27lp+u42Bch0sFmvGADyvJApkxlLm3r1O0 va+xS3Yk2yYsRoGkD/zNee4= X-Received: by 2002:a05:6000:1789:b0:1ea:7bb7:312c with SMTP id e9-20020a056000178900b001ea7bb7312cmr3861415wrg.660.1645740926020; Thu, 24 Feb 2022 14:15:26 -0800 (PST) Received: from localhost (cpc154979-craw9-2-0-cust193.16-3.cable.virginm.net. [80.193.200.194]) by smtp.gmail.com with ESMTPSA id r15-20020a05600c35cf00b003808165fbc2sm584330wmq.25.2022.02.24.14.15.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 14:15:25 -0800 (PST) From: Colin Ian King To: Saeed Mahameed , Leon Romanovsky , "David S . Miller" , Jakub Kicinski , Nathan Chancellor , Nick Desaulniers , Roi Dayan , netdev@vger.kernel.org, linux-rdma@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH] net/mlx5e: Fix return of a kfree'd object instead of NULL Date: Thu, 24 Feb 2022 22:15:24 +0000 Message-Id: <20220224221525.147744-1-colin.i.king@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Currently in the case where parse_attr fails to be allocated the memory pointed to by attr2 is kfree'd but the non-null pointer attr2 is returned and a potential use of a kfree'd object can occur. Fix this by returning NULL to indicate a memory allocation error. Addresses issue found by clang-scan: drivers/net/ethernet/mellanox/mlx5/core/en_tc.c:3401:3: warning: Use of memory after it is freed [unix.Malloc] Fixes: 8300f225268b ("net/mlx5e: Create new flow attr for multi table actions") Signed-off-by: Colin Ian King --- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c index 76a015dfc5fc..c0776a4a3845 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -3398,7 +3398,7 @@ mlx5e_clone_flow_attr_for_post_act(struct mlx5_flow_attr *attr, if (!attr2 || !parse_attr) { kvfree(parse_attr); kfree(attr2); - return attr2; + return NULL; } memcpy(attr2, attr, attr_sz); -- 2.34.1