From patchwork Mon Jan 26 09:53:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 5707501 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3111FC058D for ; Mon, 26 Jan 2015 09:53:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 692BA2011D for ; Mon, 26 Jan 2015 09:53:52 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 6B3012011B for ; Mon, 26 Jan 2015 09:53:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C3BC36E229; Mon, 26 Jan 2015 01:53:49 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wg0-f48.google.com (mail-wg0-f48.google.com [74.125.82.48]) by gabe.freedesktop.org (Postfix) with ESMTP id BBB726E229 for ; Mon, 26 Jan 2015 01:53:47 -0800 (PST) Received: by mail-wg0-f48.google.com with SMTP id x12so7953410wgg.7 for ; Mon, 26 Jan 2015 01:53:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=XD3l68B2Gm9mgZMZzLlPOujNm/jJUtnrwd/E0smnbTE=; b=JF2NJSSTyAjLaa1xQKuwtmBRMBF02dM6/dCZ7R0+VPgSMaiBNxCpL4j0EKU550jvc1 x7J5gF8460iFbmqdZewBpoD3SV1o9ich7p1+66aS2CA0VymvDxn1DTHrEyMFnOKnA97K dAOW1uVkfdNadt7c3/yO7K60em+y+Nl2S+psB0kb14roc1Y8/sHV+qkjsfX4U+sHY5HH DIgj2E93VlawHZNv2sgjYDHUzFFTgvhyWA4JOqiFOkEQZDs797yzHm5RT4Oo7nYIaxtl hfFN4E6YfflABVgujoz+QRLytiH6gx5TloNJxDNmcHUkMzIF0pCTleotXPjz1ylCP9Kw JIBg== X-Received: by 10.194.75.195 with SMTP id e3mr26073379wjw.44.1422266026069; Mon, 26 Jan 2015 01:53:46 -0800 (PST) Received: from localhost (port-49567.pppoe.wtnet.de. [46.59.194.58]) by mx.google.com with ESMTPSA id uq1sm13599981wjc.14.2015.01.26.01.53.44 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Jan 2015 01:53:45 -0800 (PST) Date: Mon, 26 Jan 2015 10:53:44 +0100 From: Thierry Reding To: Jani Nikula Subject: Re: [GIT PULL] drm/panel: Changes for v3.20-rc1 Message-ID: <20150126095343.GA3508@ulmo> References: <1422021366-4137-1-git-send-email-thierry.reding@gmail.com> <87a915hpuf.fsf@intel.com> MIME-Version: 1.0 In-Reply-To: <87a915hpuf.fsf@intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: 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-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Jan 26, 2015 at 11:07:52AM +0200, Jani Nikula wrote: > On Fri, 23 Jan 2015, Thierry Reding wrote: > > Thierry Reding (4): > > drm/mipi-dsi: Avoid potential NULL pointer dereference > > I can't find this one, has it been posted on the list? I thought it had, but I can't find any record of that. It certainly was reported on-list: Subject: re: drm/dsi: Add message to packet translator Message-ID: <20141216235305.GC31467@mwanda> I've attached the patch for convenience. Thierry From 903c75cb0da218e3849fff3c2c17a9f2ab5705ba Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Fri, 5 Dec 2014 11:46:56 +0100 Subject: [PATCH] drm/mipi-dsi: Avoid potential NULL pointer dereference The mipi_dsi_packet_create() function dereferences the msg pointer before checking that it's valid. Move the dereference down to where it is required to avoid potentially dereferencing a NULL pointer. Reported-by: Dan Carpenter Signed-off-by: Thierry Reding --- drivers/gpu/drm/drm_mipi_dsi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c index c0644bb865f2..2d5ca8eec13a 100644 --- a/drivers/gpu/drm/drm_mipi_dsi.c +++ b/drivers/gpu/drm/drm_mipi_dsi.c @@ -323,8 +323,6 @@ EXPORT_SYMBOL(mipi_dsi_packet_format_is_long); int mipi_dsi_create_packet(struct mipi_dsi_packet *packet, const struct mipi_dsi_msg *msg) { - const u8 *tx = msg->tx_buf; - if (!packet || !msg) return -EINVAL; @@ -353,8 +351,10 @@ int mipi_dsi_create_packet(struct mipi_dsi_packet *packet, packet->header[2] = (msg->tx_len >> 8) & 0xff; packet->payload_length = msg->tx_len; - packet->payload = tx; + packet->payload = msg->tx_buf; } else { + const u8 *tx = msg->tx_buf; + packet->header[1] = (msg->tx_len > 0) ? tx[0] : 0; packet->header[2] = (msg->tx_len > 1) ? tx[1] : 0; } -- 2.1.3