Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3342037rwd; Mon, 29 May 2023 09:02:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4y/oSh4NTmNsdWuUmqyNSTOIlGmixnjvbZIbRZRuNjfxwwlp4sgsShQ7gJBMV8BV8qgwUw X-Received: by 2002:a17:90a:4b4f:b0:256:31f3:1f03 with SMTP id o15-20020a17090a4b4f00b0025631f31f03mr11101587pjl.21.1685376154433; Mon, 29 May 2023 09:02:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685376154; cv=none; d=google.com; s=arc-20160816; b=YENRPff/A+dcUFSWjaprOf0cfFvluY/bZgU3vA9wwLZINMpcVoFFtcKL8qTq66O2B0 rr9sRja+cOmuWcjV/uNsoFduSCdDK2Kol3Vp0sz6zhuecYaEO7644SE/+O2501O1NXNC npJamyFEN4j0PKmMSxKtKvih4RETu3ZUShESpszjEDuQ3rijka6GGeTipdBjpt7Ch+Tu GlU50O9OvgJmlfOlaakDnQg+E6WwYLCLVqr+hd9sSP9I9klwhjEKBnJriDT8c8rxsTQd 8S5N8nldgf3FnZTMzpLWopW+uHWu7RxRfypYd16vBYbucF3PkA1rFL2UxO1071h19PVF hxbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=L//detjb5kBzA6uy4kwewHuN6E7xSSi6zXOv7sevG+4=; b=gt/hGT5xuZpSf4zFKrBWobDZ07jhjuizooP3LDR/KpphLO/QSv2cITgKD2ZVOaVjwa F6/gLvcCkm52QXN5drOnq5VMjTSGBjRYzg1DX+drAWHyHAB2ZatXxrfQ4imYuuro3wor dynH0dWf/LkMYAX3dsL1z7APZBzG83z+ZdJsCxuagQHmHvBiq0aybYc6JJB0ptO2rtyc 2Mb4R0YANuQ3EWELW7mCF+NHn/fPgQNmP3gBdiSEMHD96g/Hq8ZrJCICTlWqOSCAhJNy KgCQJ4UsC97e02PPbXz7nIi/rb5yWBpQycChvldrolrBh5m7fWPawbryEjwNhYFn/sCT VU/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=A7BM+VIG; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u21-20020a17090ae01500b0024ddf3f8a0bsi403529pjy.82.2023.05.29.09.02.17; Mon, 29 May 2023 09:02:34 -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=@redhat.com header.s=mimecast20190719 header.b=A7BM+VIG; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230060AbjE2Prm (ORCPT + 99 others); Mon, 29 May 2023 11:47:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229677AbjE2Prl (ORCPT ); Mon, 29 May 2023 11:47:41 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2EA7CD for ; Mon, 29 May 2023 08:46:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685375211; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L//detjb5kBzA6uy4kwewHuN6E7xSSi6zXOv7sevG+4=; b=A7BM+VIG0MxfwIvCEcjM4kZsefyx7WzxQQPOgLRMemGiIKfHegr/aTcoe8Li8godZ8ZlTK ugkISzlEze3ndQ6r0Gt7SBKGHoLrN42NzkOzLIFRuha91hwCYSVfcbRYOjMxAOO7bB950M kWcDMD1fACZ/+TVy8IsXWeVdqsYKUOI= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-394-KLwHRl7-OqSyOdTCZs-_DA-1; Mon, 29 May 2023 11:46:50 -0400 X-MC-Unique: KLwHRl7-OqSyOdTCZs-_DA-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-94a348facbbso379952666b.1 for ; Mon, 29 May 2023 08:46:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685375209; x=1687967209; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=L//detjb5kBzA6uy4kwewHuN6E7xSSi6zXOv7sevG+4=; b=kF1k1jh2REfm+uwUzi0DTd1UHot8p9J+veALKOEkmMfCxX4+3JIJ2FZwdIQ42zwDc8 CygiVggbGyZR5sZSdhzp9vDOjbimwdm/iTN3MFv/697FBTUJ8LzFYCLVFH6LG5JTzjnq Ifo07/PowQKU2pBq9XDhyFCjHtgCyucgwNg/x3T6E2bnX21YrWlvJR9l1C4LINO6AaGt Cb8ZuRFrfi5OM+MS/hiISlHOZM4IAw+WyzDEeXm8ab0XMQmjtAkhBkCg2Sclp4q05QSa pEq8oSdWBKUom50lGgf7EYaliRmCRfEyjfeAYaBePLuap0aSROsY2N5knSzVCkoJBimc XM1A== X-Gm-Message-State: AC+VfDwPhLEqTt/E19ZjZLPKGPLcyNwvOBduwuM6zm96TFnnPcksXfV3 69cwNzItwMpULH/Qi0JyZQRRn3vvWWxneeUCH0LFnzUJopyLXPfBDp0htvQBbop9n/k4ezdXMJc iImo4oDVvAGQiUFpZID8EFX/v X-Received: by 2002:a17:907:3e05:b0:96f:a0ee:1143 with SMTP id hp5-20020a1709073e0500b0096fa0ee1143mr13247547ejc.10.1685375209224; Mon, 29 May 2023 08:46:49 -0700 (PDT) X-Received: by 2002:a17:907:3e05:b0:96f:a0ee:1143 with SMTP id hp5-20020a1709073e0500b0096fa0ee1143mr13247524ejc.10.1685375208880; Mon, 29 May 2023 08:46:48 -0700 (PDT) Received: from ?IPV6:2001:1c00:c32:7800:5bfa:a036:83f0:f9ec? (2001-1c00-0c32-7800-5bfa-a036-83f0-f9ec.cable.dynamic.v6.ziggo.nl. [2001:1c00:c32:7800:5bfa:a036:83f0:f9ec]) by smtp.gmail.com with ESMTPSA id j23-20020a17090643d700b0095850aef138sm6050097ejn.6.2023.05.29.08.46.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 29 May 2023 08:46:48 -0700 (PDT) Message-ID: Date: Mon, 29 May 2023 17:46:47 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH] media: atomisp: move the sanity checks before variable dereferences To: Dongliang Mu , Mauro Carvalho Chehab , Sakari Ailus , Greg Kroah-Hartman , Andy Shevchenko Cc: linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org References: <20230529152136.11719-1-dzm91@hust.edu.cn> Content-Language: en-US, nl From: Hans de Goede In-Reply-To: <20230529152136.11719-1-dzm91@hust.edu.cn> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Hi, On 5/29/23 17:21, Dongliang Mu wrote: > Smatch reports: > > sh_css_load_firmware() warn: variable dereferenced before check 'fw_data' > > The variable fw_data can be NULL in sh_css_load_firmware, resulting in > NULL pointer dereference. > > Fix this by moving the sanity checks before variable dereferences. > > Signed-off-by: Dongliang Mu Thank you for your patch, but the same patch has already been submitted and merged into my media-atomisp branch about a week ago: https://git.kernel.org/pub/scm/linux/kernel/git/hansg/linux.git/commit/?h=media-atomisp&id=c09907049eea9f12e959fb88c02a483a4c5eee89 > --- > drivers/staging/media/atomisp/pci/sh_css_firmware.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/staging/media/atomisp/pci/sh_css_firmware.c b/drivers/staging/media/atomisp/pci/sh_css_firmware.c > index e7ef578db8ab..38b757c3df0a 100644 > --- a/drivers/staging/media/atomisp/pci/sh_css_firmware.c > +++ b/drivers/staging/media/atomisp/pci/sh_css_firmware.c > @@ -229,6 +229,10 @@ sh_css_load_firmware(struct device *dev, const char *fw_data, > struct sh_css_fw_bi_file_h *file_header; > int ret; > > + /* some sanity checks */ > + if (!fw_data || fw_size < sizeof(struct sh_css_fw_bi_file_h)) > + return -EINVAL; > + > firmware_header = (struct firmware_header *)fw_data; > file_header = &firmware_header->file_header; > binaries = &firmware_header->binary_header; > @@ -243,10 +247,6 @@ sh_css_load_firmware(struct device *dev, const char *fw_data, > IA_CSS_LOG("successfully load firmware version %s", release_version); > } > > - /* some sanity checks */ > - if (!fw_data || fw_size < sizeof(struct sh_css_fw_bi_file_h)) > - return -EINVAL; > - > if (file_header->h_size != sizeof(struct sh_css_fw_bi_file_h)) > return -EINVAL; >