Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp433621pxb; Wed, 3 Mar 2021 07:00:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJzf9kjYxVoM4e11fD8Cs3Ry1NnvabHJQIalIjkp+Umkk9kALWsIAf/bzIKq/7fsuMRMTIIy X-Received: by 2002:a05:6402:50c6:: with SMTP id h6mr25608160edb.117.1614783601438; Wed, 03 Mar 2021 07:00:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614783601; cv=none; d=google.com; s=arc-20160816; b=np6MlDAMXqWg71AMbRtGd3HeZ+NZAxjH8cGPWsteLQxK2XstYzqKpS6ziXLbs0LtDB XofeUUUROxaUq/YnoeIa9XvjQ6n21x5EGmsCdBaDfDa9RMA7M2nK0WijlHR86wDWXEMN 2fVRKZQES7JoR8saB1zjYxdy1N3tw41U/68euWRoa4llFkTeYA1X55wCO1WOWuyYCdhB GxLCMeI+PTTF9pw8b2NVLtQIlMET9upP88lCI1gFVKZzsYY8L//NVHyRR6s0+4xB9RqG RLUBabBFylI8JNxWzvqhLivGE43+PJNbzRPPOZk51iD2wdxwTtjSL9njDchrsoMa9FIb rlRw== 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=I4JcymNgwoOYqVm5IHJVkjq7f6RaOL8UavBT1nFgwHo=; b=hYJ/hnEqnMGWyP8+BhhSWL5nq3JYnZyEjR6E+3KNWYNUem998ebeOJ0KCtsF5zVZy4 FNJSelyHQkP1LIrXEJNf8/Hi6sG/V4eQBv9+himgpLhXV0LGxaPNh7BEmbk2r0JPuHxv VtoT68BMY1pLVyzVIAWJT6bavzwU6IXZyKl7AcyW9/nM5FaObVG47L31gIFqIGQb4TNq mh7zXUje7xp2gv7rXyNu2ojEh1IADQMKM51R/bg6tqwDMNdh3a2Qp4EKg8TDD8mOeXWw W3w2VguhCicCMGSzArpHQLb9zinNnNttOfgIsRitvd7ODgpVVkyujarNahTLhzVZ6wL+ S1pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MbrWWGn1; 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 r25si2786261ejs.195.2021.03.03.06.59.31; Wed, 03 Mar 2021 07:00:01 -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=MbrWWGn1; 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 S242284AbhCAW1N (ORCPT + 99 others); Mon, 1 Mar 2021 17:27:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:54070 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238477AbhCARdf (ORCPT ); Mon, 1 Mar 2021 12:33:35 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2719C650A5; Mon, 1 Mar 2021 16:53:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614617599; bh=Vzqect8iqBfz4kLKMHHOZAN2PO5gDDzl1cJCQMhT9WA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MbrWWGn1thlhkwLsQXzjrGuRWlKoyLrIMJddrQ2tRvxmPuZbZkFOvSQqY/pLv4YD1 faT0QXyxaz9V0PRso+PhW54p6C86JQ53iPo7C16puzu9qvQdxAB8z/vXgHuLc1i0Gu zK7iqoKBhHOBGkTYldg2eirBpwWsztyd/wGGaE5Q= 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 5.4 100/340] media: cx25821: Fix a bug when reallocating some dma memory Date: Mon, 1 Mar 2021 17:10:44 +0100 Message-Id: <20210301161053.254277161@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161048.294656001@linuxfoundation.org> References: <20210301161048.294656001@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 41be22ce66f3e..44839a6461e88 100644 --- a/drivers/media/pci/cx25821/cx25821-core.c +++ b/drivers/media/pci/cx25821/cx25821-core.c @@ -976,8 +976,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