Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3608064pxb; Mon, 24 Jan 2022 13:24:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJz5ECBWfl982kE15LzYBwkw8+YGJI+21fJhPB5y/y7rg+S1+rWApw6KGknSoU0ePlgqozNV X-Received: by 2002:a63:2a92:: with SMTP id q140mr7519153pgq.361.1643059497771; Mon, 24 Jan 2022 13:24:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643059497; cv=none; d=google.com; s=arc-20160816; b=Fx22gHmaOacKKQD3MKQC08CPXWZUP4xPN9prEUQP+LBQuRkQgL6FKyAUuwdF2raNar vU74h/ILzFrOhHMLR4DgeGdaeHhKQOfp9/+xonRTglechrpWEC21ae/20Ufr9QKwzuIb eVg/KHz/SYzJkOV0ZJWGaWZPK8APx38k2bz+qNWT4SFoGhqG7esSXQFHx53OHlai+hmd 7NrrT0WUKCFJ+r12CskHylMZB6dQvkB9PbOwSdwx94IlhjwF8qoLs41tUxgUaPE2kvjs mOG492vjBZNaQQvekw8NG6f2IDwSLBPWJgG9I6ko5bhN5+lesUoU0V0nkccK07AzlTJr J9vA== 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=dX20c9aF4ZeVa+fyEviBWKNlITfY2zKIPRwQ068OtG0=; b=jw0h8K0lc+dgwfaWdEwQNs4/NCpykOC+JL53GMP07qc/O8q6ejeQEkrSTM/XMkyzFQ oAZiKlG7mCAZIu0/7nj2dVD0d8SOlCZmoIfacHDNOXm8gIaZO2jfyLxEMt9m9wPeUvQV mTEUiaLmgrxxGAO0hGQAjEIA8WZjdFTri4t9V3x1qjm5vrmcJRxvx3P2LbmXoy8XwhBw CMdY5zQJJNfiNcjIg4aSsxW4IZDMBdLpo9BcfKCxcbnnAIbPYgy5LU4N/cT2yeiD3Mk+ F9dVSKMODkC1+e6QwmmQqZ0o8b0t8zwSSmcGueHWmgJs6iiBnEe1gx7eNBroiB0bU6nz O8mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Re8pzJ5q; 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 c1si16476614pfv.225.2022.01.24.13.24.45; Mon, 24 Jan 2022 13:24:57 -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=Re8pzJ5q; 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 S1443532AbiAXU5N (ORCPT + 99 others); Mon, 24 Jan 2022 15:57:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386440AbiAXUfa (ORCPT ); Mon, 24 Jan 2022 15:35:30 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54643C02C308; Mon, 24 Jan 2022 11:48:52 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 111B9B8122A; Mon, 24 Jan 2022 19:48:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DCFAC340E7; Mon, 24 Jan 2022 19:48:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643053729; bh=Yp1NnFfvlH+1ASCwb2Hc7AdUpcyrvhhExdH1MabsrVw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Re8pzJ5qsdd6Si+w4sXiRmwzAOLqOLAhxtB4X99mO6WfcSizoPfrKgoHc4U9ztXO+ Ey5qkzr/OQLL47Z+RkdZKxVKiJesKO2JuCa5DpiaVUtkQa/+Z0osfZT3htz8Hrf5ys oX6VSLBagNl/N5EhjXVhe1N8nJGntQnJjcPrNMYs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhou Qingyang , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.10 141/563] media: dib8000: Fix a memleak in dib8000_init() Date: Mon, 24 Jan 2022 19:38:26 +0100 Message-Id: <20220124184029.274901219@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184024.407936072@linuxfoundation.org> References: <20220124184024.407936072@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: Zhou Qingyang [ Upstream commit 8dbdcc7269a83305ee9d677b75064d3530a48ee2 ] In dib8000_init(), the variable fe is not freed or passed out on the failure of dib8000_identify(&state->i2c), which could lead to a memleak. Fix this bug by adding a kfree of fe in the error path. This bug was found by a static analyzer. The analysis employs differential checking to identify inconsistent security operations (e.g., checks or kfrees) between two code paths and confirms that the inconsistent operations are not recovered in the current function or the callers, so they constitute bugs. Note that, as a bug found by static analysis, it can be a false positive or hard to trigger. Multiple researchers have cross-reviewed the bug. Builds with CONFIG_DVB_DIB8000=m show no new warnings, and our static analyzer no longer warns about this code. Fixes: 77e2c0f5d471 ("V4L/DVB (12900): DiB8000: added support for DiBcom ISDB-T/ISDB-Tsb demodulator DiB8000") Signed-off-by: Zhou Qingyang Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/dvb-frontends/dib8000.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/media/dvb-frontends/dib8000.c b/drivers/media/dvb-frontends/dib8000.c index bb02354a48b81..d67f2dd997d06 100644 --- a/drivers/media/dvb-frontends/dib8000.c +++ b/drivers/media/dvb-frontends/dib8000.c @@ -4473,8 +4473,10 @@ static struct dvb_frontend *dib8000_init(struct i2c_adapter *i2c_adap, u8 i2c_ad state->timf_default = cfg->pll->timf; - if (dib8000_identify(&state->i2c) == 0) + if (dib8000_identify(&state->i2c) == 0) { + kfree(fe); goto error; + } dibx000_init_i2c_master(&state->i2c_master, DIB8000, state->i2c.adap, state->i2c.addr); -- 2.34.1