Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2452488rwr; Fri, 28 Apr 2023 10:28:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4MHI4gE33/RipXn8HbVNCZ1PohwGGx7Q+lB/s2/IBVeHLT1zxBdeAuf+RBzCoO/cjWDZy2 X-Received: by 2002:a05:6a00:248b:b0:63f:ffd:5360 with SMTP id c11-20020a056a00248b00b0063f0ffd5360mr9342118pfv.21.1682702915226; Fri, 28 Apr 2023 10:28:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682702915; cv=none; d=google.com; s=arc-20160816; b=HNOWPtf2I3lqtk+mxCwdCZWzpTb1ahMdPcHuF2z3xuaYjjoDCjdkAuOaxkaojw7Skf XPvIqtBw4c8IYNV5HrBE1uFerY/3L6p/2bsot0MtM2vV3uC/DPGUjKsQxCkU/7UE9VL5 nbofjwXI+AC9ImthRllB28rogvounqcs/6afyYp3NbEPMQN/wqwJhEpWS24/1G0uyiX4 Rd1oU88oKugefARxu0Iwwt/1TjtSENhRpHNk4toJ/ddnLuwd3yrtWh5KHHf9raS9wloI 8XdrCn3aXYXVQoJJ3nC5tSlhnFzVV7ZSA2qeSkv1KIyHuQJTQVQirPYFJK9sESnG2NId RbFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=dr/x1YXmoYbcw8pzPoqQLEXTHcHWLPAeJrUeQycbqeI=; b=g6+PO9k1e2GMgOqm4aKG98N/NBGbQBDZuAB5OcSbPSsyY1jAzpUxfzK03bO5a7y7aP dp2P5Q1Io8ViFG88I7XAWc/JYKo0rNkNebC1GVzPawnxiNSnvdP0B5Hm4d/tpbcDLU1D Bt7C5CyOQntZIY3LQEkDCXWoZnDVlMqk5ndmgrOMiPtwarOA7wOTb9EfJNIBeebd0tXM Y2NZRhFJ809wXYojGBLS+/eQEv8XkQnxQRKS3VVZaF2VXa2f62CAFdzOylwedSxm6Q9k DMhSjaDASPH5G/rf60o9kpYvagXTflvhb3D7ZYgOL/6SpwdbJUTvv/0OW0kuH8V9S+JA WdGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="mpSa/cBm"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y19-20020a634953000000b0051fb9c77447si20816306pgk.477.2023.04.28.10.28.23; Fri, 28 Apr 2023 10:28:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="mpSa/cBm"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1346341AbjD1R2T (ORCPT + 99 others); Fri, 28 Apr 2023 13:28:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346309AbjD1R2R (ORCPT ); Fri, 28 Apr 2023 13:28:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C35830D5 for ; Fri, 28 Apr 2023 10:28:07 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 39D08644E0 for ; Fri, 28 Apr 2023 17:28:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83EB9C4339E for ; Fri, 28 Apr 2023 17:28:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682702886; bh=awzlaeaMJVwFKmd4eU3dpKmk4Ck+BaGjudrb7tg482Q=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=mpSa/cBmj2Xf/Og6E2MVuM86bg7KoArkd+R9npdtcWIZdgS/QlvNlN7HApdJJPj+o QEp0ofqOZ7XUCRgIBYE6AbzDFPs9eZjH+wYSg3ypO/SREJVl8KkYDV1VSUgD52ZVoM pck/f1RtXnV6kgHUIvN7Yt1ioFpeuPB5972rTqzB7k0eiTT8yU1jxkYp35TtvcyaWD c9Jni6GuGbFCbHokR6cls9ft9asL6vONlZa1jhqVXNP8ZziJ1voZkXDQyA2AbH4hYq 3PEIc9yi/bxTKvh8V8ODYC81+7t7NpYfZLs3z52jPpMhEGWF8HHm4I77LbXs/1n/a+ XHkWyLYcTq3sw== Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-247048f86c7so160425a91.2 for ; Fri, 28 Apr 2023 10:28:06 -0700 (PDT) X-Gm-Message-State: AC+VfDxwuy0AnCiOha6Mf73xFFryLwZbeBz6WALujEDQE54TuB9uLaGE xfE+hXul37tDVAoEEClPc8ETHCnz12wkB1PS7QGjVA== X-Received: by 2002:a17:90b:4ac3:b0:24c:1de9:493 with SMTP id mh3-20020a17090b4ac300b0024c1de90493mr4272026pjb.47.1682702885951; Fri, 28 Apr 2023 10:28:05 -0700 (PDT) MIME-Version: 1.0 References: <40c60719-4bfe-b1a4-ead7-724b84637f55@web.de> <1a11455f-ab57-dce0-1677-6beb8492a257@web.de> <14636275-4d26-d639-5f6e-293fc6d1c4c6@web.de> <6f758653-36c9-91a2-7bbc-278ae3f8ccee@web.de> <14083012-2f19-3760-a840-d685fcedc15e@web.de> In-Reply-To: From: Robert Foss Date: Fri, 28 Apr 2023 19:27:54 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH resent] drm/bridge: it6505: Move a variable assignment behind a null pointer check in receive_timing_debugfs_show() To: Markus Elfring Cc: kernel-janitors@vger.kernel.org, dri-devel@lists.freedesktop.org, Andrzej Hajda , AngeloGioacchino Del Regno , Daniel Vetter , David Airlie , Hermes Wu , Hsin-yi Wang , Jernej Skrabec , Jonas Karlman , Laurent Pinchart , Neil Armstrong , LKML , cocci@inria.fr Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 28, 2023 at 5:56=E2=80=AFPM Markus Elfring wrote: > > From: Markus Elfring > Date: Sun, 16 Apr 2023 17:30:46 +0200 > > The address of a data structure member was determined before > a corresponding null pointer check in the implementation of > the function =E2=80=9Creceive_timing_debugfs_show=E2=80=9D. > > Thus avoid the risk for undefined behaviour by moving the assignment > for the variable =E2=80=9Cvid=E2=80=9D behind the null pointer check. > > This issue was detected by using the Coccinelle software. > > Fixes: b5c84a9edcd418cd055becad6a22439e7c5e3bf8 ("drm/bridge: add it6505 = driver") > Signed-off-by: Markus Elfring > --- > drivers/gpu/drm/bridge/ite-it6505.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge= /ite-it6505.c > index abaf6e23775e..45f579c365e7 100644 > --- a/drivers/gpu/drm/bridge/ite-it6505.c > +++ b/drivers/gpu/drm/bridge/ite-it6505.c > @@ -3207,7 +3207,7 @@ static ssize_t receive_timing_debugfs_show(struct f= ile *file, char __user *buf, > size_t len, loff_t *ppos) > { > struct it6505 *it6505 =3D file->private_data; > - struct drm_display_mode *vid =3D &it6505->video_info; > + struct drm_display_mode *vid; > u8 read_buf[READ_BUFFER_SIZE]; > u8 *str =3D read_buf, *end =3D read_buf + READ_BUFFER_SIZE; > ssize_t ret, count; > @@ -3216,6 +3216,7 @@ static ssize_t receive_timing_debugfs_show(struct f= ile *file, char __user *buf, > return -ENODEV; > > it6505_calc_video_info(it6505); > + vid =3D &it6505->video_info; > str +=3D scnprintf(str, end - str, "---video timing---\n"); > str +=3D scnprintf(str, end - str, "PCLK:%d.%03dMHz\n", > vid->clock / 1000, vid->clock % 1000); > -- > 2.40.0 > Applied to drm-misc-next.