From patchwork Wed Dec 6 13:07:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 10096533 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2EEB860210 for ; Wed, 6 Dec 2017 16:45:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F373285E2 for ; Wed, 6 Dec 2017 16:45:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 13FDD28AC7; Wed, 6 Dec 2017 16:45:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A680C285E2 for ; Wed, 6 Dec 2017 16:45:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DCF286E66B; Wed, 6 Dec 2017 16:45:14 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 12927 seconds by postgrey-1.35 at gabe; Wed, 06 Dec 2017 16:45:13 UTC Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6FF876E66B for ; Wed, 6 Dec 2017 16:45:13 +0000 (UTC) Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.21/8.16.0.21) with SMTP id vB6D7c5n126366; Wed, 6 Dec 2017 13:08:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2017-10-26; bh=xCqzsSIxBStpwCrHiaC3AaaDvZNTQVwTv8Erhyjdqao=; b=q/wwFvoQMyz7+ceLe1Z+WISdLlVRjn7QdRwBcIuNEoah0/59xwFaLjLV9wzjYHtI9UIC DA9s5/U34vjvGwKPvPei1A2HSqryi55FqKNyWTwQ/UY1/P4cSvv9+RV3j0w3lMPD7J4H mZrJ6CKd1Hxqnaf1wKsWki5tvD24OD8Wfa+J9q5VFLqdhtzcrdjgfUzQX6yrnr4qz17S r53qFALfpNJuK1fF4Ux5CyKYELHXmlRf7kY77ItU9rUMjRP/styiBK9LIFPU3ZIbAhfK CUZSq2tlujH84VYb+RnyVGjDIEJooac/XciT7KgYLc78a1QaUF+g/lp2DiHe0QaPPh7Q uA== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2epd12gtw4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 06 Dec 2017 13:08:40 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id vB6D8dbA016947 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 6 Dec 2017 13:08:39 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id vB6D8b4I021906; Wed, 6 Dec 2017 13:08:37 GMT Received: from mwanda (/41.202.241.19) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 06 Dec 2017 05:08:35 -0800 Date: Wed, 6 Dec 2017 16:07:49 +0300 From: Dan Carpenter To: Daniel Vetter , Noralf =?iso-8859-1?Q?Tr=F8nnes?= Subject: [PATCH] drm/fb-helper: Fix a potential NULL dereference Message-ID: <20171206130749.64efknoi6r7w3jqa@mwanda> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: NeoMutt/20170609 (1.8.3) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8736 signatures=668641 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1712060192 Cc: David Airlie , kernel-janitors@vger.kernel.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP We recently modified drm_fb_helper_single_add_all_connectors() to allow NULL "fb_helper" pointers. But the problem is that it gets dereferenced before we checked for NULL. Fixes: c777990fb45b ("drm/fb-helper: Handle function NULL argument") Signed-off-by: Dan Carpenter diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 6654f2f87775..f73457e5bbbc 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -178,7 +178,6 @@ EXPORT_SYMBOL(drm_fb_helper_add_one_connector); */ int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper) { - struct drm_device *dev = fb_helper->dev; struct drm_connector *connector; struct drm_connector_list_iter conn_iter; int i, ret = 0; @@ -187,7 +186,7 @@ int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper) return 0; mutex_lock(&fb_helper->lock); - drm_connector_list_iter_begin(dev, &conn_iter); + drm_connector_list_iter_begin(fb_helper->dev, &conn_iter); drm_for_each_connector_iter(connector, &conn_iter) { ret = __drm_fb_helper_add_one_connector(fb_helper, connector); if (ret)