From patchwork Sun Oct 8 14:36:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Sakharov X-Patchwork-Id: 149754 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp1397124vqo; Sun, 8 Oct 2023 07:38:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH3HcLwgJWo7uE8X1wvdKtz4x7DJjSiJ8OX3DsK3h2W9efQKJCwY79BcQ9+/zyBlr3j0pxP X-Received: by 2002:a05:6a20:3204:b0:164:c705:3843 with SMTP id hl4-20020a056a20320400b00164c7053843mr10549738pzc.39.1696775890380; Sun, 08 Oct 2023 07:38:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696775890; cv=none; d=google.com; s=arc-20160816; b=moAq0ElT5YzTY1gCnmsNBok6vPS4iQWxnW0gFtUESYAsIOujeh7CsS2iidwKmM7tgE ltj/xmgtdkoJIp8EffO3N86B0QAj00FuKh9brZhyVOzw1xqLLuSvEINu/wCP8VDUnssc UCpCmR9BhdxFMlGk2PayHCV4xZMGPEgnQ0FDSf2+BzvMPj+lbIAK/tmrldQkzxTP34cd icYIDE3BZQEY90acn19sEGAJ0E1Qr3khzXQD6a82AYBQVPMvfSu+AgFzsAjiSC3bsi+/ 7SaKbj1d4GQQC40y1+n9vr4BV82AryDNdkJC0xNwG+/cHrFHRnt2nETjttBO165PGJEP nP/g== 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:dkim-filter; bh=RoI0NzZPsRKEzf3D3JCemfXog6bSvCczYoK0HGBz6tk=; fh=o3TQe9DYTZYpfekWW2YnKGgMaQ3WKUt1ZeOSahlpawI=; b=Bb4a07CCsi1dGoNvczAytiVYBvsycRjaGIBlr4yk0QwrHGw9zTb4q5DufjngoMe73p Ed2E0NmcP96dGgDDVH0ZNv2WcaFbJMq3D1jt+FkOOlZnqZE1q65Ku+oqd/zcTsKAQ3Re 5cbDOUW9zQgfcp06SqyaSwio2zh4OEwXqUB9N7BV/2bAZ/vw6g7fe2R/9BI6ehbqEUd2 ruXif0FPxlAOJUr1VkcfKdjnp3Yg3ZO/aKXazSoiUSBBvEhGQNnKl0JsVjK1vBvUHr+y GBsnyWv4NSr1x8wVXzjXXzud4l9s/1vixZUhm1076Bqq9fDpj9EB7iUj39WkAw0HdRh7 oaGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=Q8eNVony; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id o20-20020a170903301400b001b89bd6fd59si7484685pla.215.2023.10.08.07.38.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Oct 2023 07:38:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=Q8eNVony; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 623088026821; Sun, 8 Oct 2023 07:38:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230082AbjJHOhE (ORCPT + 18 others); Sun, 8 Oct 2023 10:37:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232990AbjJHOhC (ORCPT ); Sun, 8 Oct 2023 10:37:02 -0400 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F387EA4; Sun, 8 Oct 2023 07:37:00 -0700 (PDT) Received: from localhost.localdomain (unknown [85.89.126.105]) by mail.ispras.ru (Postfix) with ESMTPSA id 4C4ED40F1DEB; Sun, 8 Oct 2023 14:36:57 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 4C4ED40F1DEB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1696775817; bh=RoI0NzZPsRKEzf3D3JCemfXog6bSvCczYoK0HGBz6tk=; h=From:To:Cc:Subject:Date:From; b=Q8eNVonyqxFLuwSGdRKO3poe5TFCrbHZorXms5AfSGQK/RYBvjDy5T6lJiNKTtKEM hisIozg7H45+6TZ4xM8DJF6FYvAC9qaMwpwZqpNpB2BIEmZfmAvjT3znNBXzTMpn4m y6DKkfx+IMycG/5rg0CdUm8BDz8h7RMB1UfPG9cQ= From: Pavel Sakharov To: Sumit Semwal Cc: Pavel Sakharov , =?utf-8?q?Christian_K=C3=B6nig?= , Arvind Yadav , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org, Alexey Khoroshilov , lvc-project@linuxtesting.org Subject: [PATCH] dma-buf: Fix NULL pointer dereference in sanitycheck() Date: Sun, 8 Oct 2023 17:36:36 +0300 Message-ID: <20231008143637.113957-1-p.sakharov@ispras.ru> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Sun, 08 Oct 2023 07:38:08 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779198475869880910 X-GMAIL-MSGID: 1779198475869880910 If mock_chain() returns NULL, NULL pointer is dereferenced in dma_fence_enable_sw_signaling(). Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Pavel Sakharov Fixes: d62c43a953ce ("dma-buf: Enable signaling on fence for selftests") --- drivers/dma-buf/st-dma-fence-chain.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/dma-buf/st-dma-fence-chain.c b/drivers/dma-buf/st-dma-fence-chain.c index c0979c8049b5..661de4add4c7 100644 --- a/drivers/dma-buf/st-dma-fence-chain.c +++ b/drivers/dma-buf/st-dma-fence-chain.c @@ -84,11 +84,11 @@ static int sanitycheck(void *arg) return -ENOMEM; chain = mock_chain(NULL, f, 1); - if (!chain) + if (chain) + dma_fence_enable_sw_signaling(chain); + else err = -ENOMEM; - dma_fence_enable_sw_signaling(chain); - dma_fence_signal(f); dma_fence_put(f);