Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp633780pxx; Mon, 26 Oct 2020 17:34:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKAGgaRHLlg2BHV/t+ZeRHVhJ0A1g83aR5+rovuq4yUOVM3HFmix8PSAJEI5BxO2muY0G2 X-Received: by 2002:a17:906:b084:: with SMTP id x4mr8073985ejy.374.1603758890453; Mon, 26 Oct 2020 17:34:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603758890; cv=none; d=google.com; s=arc-20160816; b=csssa0th6rnoSa8Tj+5wfU0Ou4bB7pqbnS4MziZxs6QFmoqkBEL7feimYbMtofYJwt uUnp5kVAbyBice43mvh3+2TN+w/CoEBprWqqq21a8z7i2Vu186rpcWbcF7M/XVAHQDKi tPEOj3vjpP2shi0hCIta8O3RSe+Hm1yesrg68X61VMciMg8gVAg51dcnhXCBZgBcMGpJ 4mjCea692OenB39telb+yqOEYF4va7UqOiNt9U4pReYpm3HU2RYhiQs8MqIDmCArN08q IpXcM/b+7It9PEF0NzxQYvdNonmEQ5N+fPC2j0vfrehir/3XOvtsKpWPQZOPmijBFJdG dVxg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kbsVafrGV1MR6YnuJGlZlGEeQUXxl/+xwnmwzQFYZNg=; b=O6u6hjJftVYgZTh9rP/E4pKsgX0ePDIscifhxbzMKhbkHQva+rnKDpqBgky/7hOZsT jzqEA5wfT75JgDuZ7X1AG5k1r1oKh3pAyV9IRW5o+Z7fKQH6WJotyDrFUu+LBGNgU45Y 49RrhN2MUdGhFoO7VHNv6hTdemEr++Q+WIxYBp20nOseF0dBT5A89YrhxjYV+ROcFuWX fVYBDtD8EXtL0FyIhX0V8qzQcD2C/knQDvc7dkzC1fQPShQnaFImi8wupGBSZFuuYmgN W98jkIMcKIJ30MWFrcIz6ZnfAbpepqB4i64Bq52Y8e4Ke1M9Dr8FB2OKhUbnILVZRLPf zm1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IGD052Y6; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t12si11853669edc.181.2020.10.26.17.34.28; Mon, 26 Oct 2020 17:34:50 -0700 (PDT) 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=@kernel.org header.s=default header.b=IGD052Y6; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2441319AbgJ0AWd (ORCPT + 99 others); Mon, 26 Oct 2020 20:22:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:34336 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2410929AbgJZXzl (ORCPT ); Mon, 26 Oct 2020 19:55:41 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C79692151B; Mon, 26 Oct 2020 23:55:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603756540; bh=IpT/K6eK2wh43wNZVDZJWmzMRqa5zzWcj3v8qvoAwCs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IGD052Y6RGDrF/fla8t9KSmpQfXo5Tq/vTgyZun/L/+UTtKkhqjJDNqGw0B7Pk2KW 6NCXhauXhqC9klMyDdnmyRUc61r7cJBspG4FvCcwTWPzGO/kRB+xRdvGc9rrfnjL8x uBPo/Qpf49Hwvh8zlfdWcbd1s9fw79qUURx7N17w= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nadezda Lutovinova , Sam Ravnborg , Sasha Levin , dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.4 19/80] drm/brige/megachips: Add checking if ge_b850v3_lvds_init() is working correctly Date: Mon, 26 Oct 2020 19:54:15 -0400 Message-Id: <20201026235516.1025100-19-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026235516.1025100-1-sashal@kernel.org> References: <20201026235516.1025100-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nadezda Lutovinova [ Upstream commit f688a345f0d7a6df4dd2aeca8e4f3c05e123a0ee ] If ge_b850v3_lvds_init() does not allocate memory for ge_b850v3_lvds_ptr, then a null pointer dereference is accessed. The patch adds checking of the return value of ge_b850v3_lvds_init(). Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Nadezda Lutovinova Signed-off-by: Sam Ravnborg Link: https://patchwork.freedesktop.org/patch/msgid/20200819143756.30626-1-lutovinova@ispras.ru Signed-off-by: Sasha Levin --- .../gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c b/drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c index 6e81e5db57f25..b050fd1f3d201 100644 --- a/drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c +++ b/drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c @@ -295,8 +295,12 @@ static int stdp4028_ge_b850v3_fw_probe(struct i2c_client *stdp4028_i2c, const struct i2c_device_id *id) { struct device *dev = &stdp4028_i2c->dev; + int ret; + + ret = ge_b850v3_lvds_init(dev); - ge_b850v3_lvds_init(dev); + if (ret) + return ret; ge_b850v3_lvds_ptr->stdp4028_i2c = stdp4028_i2c; i2c_set_clientdata(stdp4028_i2c, ge_b850v3_lvds_ptr); @@ -354,8 +358,12 @@ static int stdp2690_ge_b850v3_fw_probe(struct i2c_client *stdp2690_i2c, const struct i2c_device_id *id) { struct device *dev = &stdp2690_i2c->dev; + int ret; + + ret = ge_b850v3_lvds_init(dev); - ge_b850v3_lvds_init(dev); + if (ret) + return ret; ge_b850v3_lvds_ptr->stdp2690_i2c = stdp2690_i2c; i2c_set_clientdata(stdp2690_i2c, ge_b850v3_lvds_ptr); -- 2.25.1