Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3547212pxb; Mon, 24 Jan 2022 11:56:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJxh+NVCt7Tj0aoKSfUIkXvDrQU/YAyQzMKYJS4vToo55jinPbRvD4uPleq8AtKipty9Gf6G X-Received: by 2002:a17:90a:d90e:: with SMTP id c14mr3463830pjv.198.1643054213283; Mon, 24 Jan 2022 11:56:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643054213; cv=none; d=google.com; s=arc-20160816; b=xp3C+XztAIlqzVuIv62CrbWPUiO1l8fe0C9po5lkBgovvSp53cBRy6FTWFGp/UUH1J vctK36rAnWYcBQlvWzQcyCqJrkYAkKMrGYUq0Fg0bGWifenzLQ5P6mfChtDs/DUKV5u4 ITL5j98KnpYdt6ONaNQFMfDiFMro1VpN0BJUw02vwYilsOo/n0UGw8zvahLiPGcCFDot RMvjWBaoMKrfIevtT7/JzVNGek6xOdjvOt9E9W9x1JT8DoZS8we7V7bJXRPrvJA2tU++ ukylF98DiHnPhLCnlqvdstKmFuuwoDjp1LjhmRw6sWp8Z0DSD0z3sSHdmqQpw+C5a2X4 U2Ww== 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=vmOOEfXRCF6mU9fUNdl6jFNFSldArKjf7nDFzJyRawI=; b=KenO/ta8urIId4q2zZcoifQ/EhEOnvTZGG00XTNKKtQW2Zg8OxPGMhboHljFXY3mN+ dcIAC0j2OuOuN9jNLrBUNJfco9dA7tA7DsfCjdg7iFAwCdA2S9oaYv5veFwxqMCGrWwL dfZkv/B+6smH8UISkx52zsMjEgi8qRvopKbt6J8VbIioH3bAmF6Z1UvyIihTOY7NdzvT tbgY09Yx/VXjv9cLx0rdjL+ajiZPx4iHftQ/9VOknno5f71qt2FMLvVoh9ZnzQ9G/Q4J wfqFbqBXPIqFuUXnDQPUs7donceOYdoVSuvZlJA4HprVctsFHd97pbLl6j2dRtk6a1rd 9X2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="v/S5oguq"; 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 nl12si317703pjb.6.2022.01.24.11.56.39; Mon, 24 Jan 2022 11:56:53 -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="v/S5oguq"; 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 S245599AbiAXSuQ (ORCPT + 99 others); Mon, 24 Jan 2022 13:50:16 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:49496 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235976AbiAXStX (ORCPT ); Mon, 24 Jan 2022 13:49:23 -0500 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 63733B8121D; Mon, 24 Jan 2022 18:49:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E366C340E5; Mon, 24 Jan 2022 18:49:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643050161; bh=rH7vXnLsMeqrHjpj2FZxMKF7MTGw1pwYc0KA4eDVaSA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v/S5oguqmVQ5gVKB1idw5OxB4KNeCoi58U3FiilpdqcJv0Y/IlHGA0HPduhAeXDx4 CVWw5C9HQ7wGkAQwwjmj7rRvw1w9E3SZ2aP9vkoTLHcpU+gy3Yvkcwmr6VBi3xnz5o CnOnw2Y3wof4o7ecGrs8Nhjirz8Wy7is1PMKXoBk= 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 4.4 030/114] media: dib8000: Fix a memleak in dib8000_init() Date: Mon, 24 Jan 2022 19:42:05 +0100 Message-Id: <20220124183928.048787958@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183927.095545464@linuxfoundation.org> References: <20220124183927.095545464@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 94c26270fff0e..b8af5a3c707f8 100644 --- a/drivers/media/dvb-frontends/dib8000.c +++ b/drivers/media/dvb-frontends/dib8000.c @@ -4461,8 +4461,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