Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp395113pxb; Wed, 3 Mar 2021 06:07:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJxscD+aGqpzjRoqF6GfevhfuKYaSySGbk8JoXDwqRwXNuglxH/g4SewvTzFjNwHIJQ6am1s X-Received: by 2002:a17:906:b747:: with SMTP id fx7mr26647878ejb.474.1614780461658; Wed, 03 Mar 2021 06:07:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614780461; cv=none; d=google.com; s=arc-20160816; b=UHGsjstxcd4bd6JaM1evNEJsj0KDjmF1dd2wrPEbbfYQLB172KQ4jkAe6XaB5c53LC +KuHsQg6f89rQXHsn3IQNH+xG/FX7oKtU244we4EfwTh9RxmJQxVb7BFR99GKgDa3Nmd d2t5b6tCAaxCX95lpbl2vQ0ALBJplCz8rhwWLfeuOMtUy3HfksSVz9n91VSFIA9q/G2p B/s3ncBcvVf3eIqd3ULp4Yw0hIpgSrftspSHB7/6HBrddU4gWNMd8Y35eoef6IyIGouB 9Is1Pbg/lv8fubHOP+UWtw6FOHHpihLv4CyDABiObKEznAN+hXpKaZn1PRMGjOiA2LSg 4w8g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xacOHjP0R23NP3tdCnyacbOMVfzkNhYQ1gNjg3tW2xM=; b=wYpZnuzSxvLF2Y6L5q3MmV/QsN3C2AG+Ao+cDyeY2nWFis9bjzBOOu0rAsCcEt92r/ /8rR/NUzAKyr6IQ09f1DlatSugpHnGhucMvODrWfFdn/1uT1NxBX0qi8xS2Mo6qbDbLK YJoCVE3a4nNNp8h/oADwmh1yU6vwnb3We0cqZuWIMsIfIbJBwjpQxSTXOMM6wSP/Onoz Q9hw+NKqlqSqHon/3VF/U308CLIC+DvE96vjPeerFbuY5eVIfHDkUAx8pkSylTeXOiR9 ETpWCjl8u0udg9cWleRSUyDSBCBGgM0Z6N+mQIFmNAaZUIOIWGMrna3i/4T9dsLBgb2N yYOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nWvbfgnv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h20si15595533ejy.416.2021.03.03.06.07.01; Wed, 03 Mar 2021 06:07:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nWvbfgnv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243399AbhCAU2b (ORCPT + 99 others); Mon, 1 Mar 2021 15:28:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:35314 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237066AbhCARGv (ORCPT ); Mon, 1 Mar 2021 12:06:51 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0B09664E66; Mon, 1 Mar 2021 16:40:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614616824; bh=232Bll8ZdN2TzUZwwao0rLw+4QBd3kJLhelNj2zaz3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nWvbfgnv6XoW7dmJK9C2/VC5Sf/vxGJyc+Fu3FEV/dOK1ikwZ5M9sQs6vG0BXR9bh r9/3KWsWZvV+G9WJORIu44t5Zv7l9HwcExq/2pm/bCfV+GidsAsdKWOqM7x1lNBblQ LtbROfrpBigxv7xFjGlxw25iPCxKZmFCGtwhZdro= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 4.19 091/247] media: cx25821: Fix a bug when reallocating some dma memory Date: Mon, 1 Mar 2021 17:11:51 +0100 Message-Id: <20210301161036.130673934@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161031.684018251@linuxfoundation.org> References: <20210301161031.684018251@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe JAILLET [ Upstream commit b2de3643c5024fc4fd128ba7767c7fb8b714bea7 ] This function looks like a realloc. However, if 'risc->cpu != NULL', the memory will be freed, but never reallocated with the bigger 'size'. Explicitly set 'risc->cpu' to NULL, so that the reallocation is correctly performed a few lines below. [hverkuil: NULL != risc->cpu -> risc->cpu] Fixes: 5ede94c70553 ("[media] cx25821: remove bogus btcx_risc dependency) Signed-off-by: Christophe JAILLET Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/pci/cx25821/cx25821-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/media/pci/cx25821/cx25821-core.c b/drivers/media/pci/cx25821/cx25821-core.c index 2f0171134f7e1..e04fe9f17b7aa 100644 --- a/drivers/media/pci/cx25821/cx25821-core.c +++ b/drivers/media/pci/cx25821/cx25821-core.c @@ -986,8 +986,10 @@ int cx25821_riscmem_alloc(struct pci_dev *pci, __le32 *cpu; dma_addr_t dma = 0; - if (NULL != risc->cpu && risc->size < size) + if (risc->cpu && risc->size < size) { pci_free_consistent(pci, risc->size, risc->cpu, risc->dma); + risc->cpu = NULL; + } if (NULL == risc->cpu) { cpu = pci_zalloc_consistent(pci, size, &dma); if (NULL == cpu) -- 2.27.0