Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp586909pxb; Wed, 3 Mar 2021 10:07:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJzMmlg/+ZlVaSbfrt6uQ6iAydL9hhRmdvnekYQFyX/AT9TIqtycVopT4R4UBxcit12Z8Ym2 X-Received: by 2002:aa7:c7c3:: with SMTP id o3mr593874eds.8.1614794837597; Wed, 03 Mar 2021 10:07:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614794837; cv=none; d=google.com; s=arc-20160816; b=hzFaO354LjxQcOKfpAzZ9q6KqhUdYdneY4lKXJPk/9SDoOh55KyZzRl+2/OrIj+hTA DFBsZ48h0Kfl28i0l8nCXRHItmgcAc+S6N1idunG0O2eYH5ox2f2bdkmdKsKO/PlVHoc +XAGPDwtaSEC/IYmgBcj/4LywU8ySoZLyJPhnH2aLh5LekAgv4RyGsbz3PjrKqbb8C8w 1xlLmQ6qLvm5u2Kclz9wHkS3t3Ln0EGF3sT4xIwq9gxMmpS4uxk0TuWAw7cbh/rG7ZQ7 mj3qegYKUE/OhBIq1tXRIb/Mk7CuKHU6xWo6GzqZEc+GOE0BoRsMdn4cKd41v2CVqd6b YaAg== 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=kvFoYRC+CID/dxgQYtvUEdpj/rfTfq4t73gXwS3WNI0=; b=yP/Te63VJUL1WKH4igxIGZj/IzqAv/Pq3Af3yBZPO9K7Ev7oakiOfHDPy4zmy2j5OI UzCCdIr/uLZNHryFtBW6mdoZs067D0qWxB/CEUG4WvKrDnQtUpYFKbZTwWmQBve/uW4x OX6y2glEA03+HKWnLqfmFjYwQUNK9yXqWl0VwtWcfGoh3PwBVrHlRwnMUt26s8NDdPWS JPxaMu5Im3zNW5Vfo5jGyUEDiHfIAI4Eeiyw2NabjFHcwX7+I40b6IXFjBhC1DC725Z2 CiQkk/RWixOJJQiLs8iwsfTC8uKJ8MgdKanyywg3wBcnXHg8yADQh39tHGzAWSa5DhM4 E6rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QM5himF2; 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 dc3si5135997edb.57.2021.03.03.10.06.20; Wed, 03 Mar 2021 10:07:17 -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=QM5himF2; 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 S1345490AbhCBBBO (ORCPT + 99 others); Mon, 1 Mar 2021 20:01:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:57720 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240399AbhCASvT (ORCPT ); Mon, 1 Mar 2021 13:51:19 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 599C76501B; Mon, 1 Mar 2021 17:12:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614618725; bh=dDrGlAYOEdD7F0y/JYY+1YNb0RaD7VHOvOfpdjXa1YM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QM5himF2RRd0mjczww1qeIdbG9PHkeMeW7M+CXT4F8Qox+n33zzCCrndtE0Zddcu9 LQ0Fm6fHe5OxLAr0QugIWmLQGKrLjtfXxgRat3IUAhAGnJB3nFWIBHPI3/ghBy1B0E MQyC+vhikLFJUEqlypBlrO2EQegLzvVq1nTKT1x4= 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.10 192/663] media: cx25821: Fix a bug when reallocating some dma memory Date: Mon, 1 Mar 2021 17:07:20 +0100 Message-Id: <20210301161151.277603049@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161141.760350206@linuxfoundation.org> References: <20210301161141.760350206@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 55018d9e439fb..285047b32c44a 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