Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp26101pxa; Tue, 18 Aug 2020 14:39:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsPxy1nQpPEcmIVIXspiIvkdzs63JhTQoOPZGW1Es6CxZ7Wyy0XAbJ+VcTZgjTwN5Frhoa X-Received: by 2002:a17:906:2f17:: with SMTP id v23mr21509526eji.343.1597786774900; Tue, 18 Aug 2020 14:39:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597786774; cv=none; d=google.com; s=arc-20160816; b=VNuVFEqErYzVcKoCzkYZJ7p1b09BniPNwVZeR/mPrgSXfcdw6K8cLvoDXIhtnGMrjr BJKDSz3d93K23edlOAFK8JDvAorP+hiwxTPs2oo0jLR2knAVl23CllRuKxz1Uea2LIQC zJYPQAi69qmCjK2zVk2ucbeenjY8wY46bquOLPrX4WqUU2vzWfL7hCqI85hyZt7OB5FW Y8QSQChlTH6ehxcW/FUU7sWoaW7YElQWJMQS5lSHaS7Oz1kUjvIm7tmQMfVkVwBM1fYT o2SokdKNcJQM5UfH+mM7vr1R4Avz1gVDA563d9nvneYjAV4nvrxVLSS8iuJi60uFuAbS mXJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=A8augpQCNkS+6V2jlgZCn5c5JK8wvV9ybfF2eTq6CFg=; b=PFsItF+YVKjtgUtMk97viUmkfV6bgwEobSpLikPHo/2tKxsP8mss0aCI9y7mqRXxYN 21PnFa/gwNNej/FW4ZglbPCTK+WxKjm/SsejbjVh0PvQ3vAKAK/797jWEL8ReK8JO5ei ++srjG9i4I+ovgm6zvE+mS5+1xOR3dXPPU1sByxjZ81Cy34JOnTdrHp3ez0XR2BOMdJG ie2+7EiMsL+4IerKG3WJ1212Zcw+sQVMDLGMdOUlTPBKK77It8zGIoSChd9yHKxbE7A7 6JxIP9x+VP/j+Sv0aBDgXiDVc/QB3LfYWBEavirpQgIKgDo7a7CNW2hAuEk7QW5WNAAB FiyQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z12si13706361edx.530.2020.08.18.14.39.11; Tue, 18 Aug 2020 14:39:34 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726945AbgHRVfA (ORCPT + 99 others); Tue, 18 Aug 2020 17:35:00 -0400 Received: from jabberwock.ucw.cz ([46.255.230.98]:44812 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726372AbgHRVe4 (ORCPT ); Tue, 18 Aug 2020 17:34:56 -0400 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 748AC1C0BB8; Tue, 18 Aug 2020 23:34:54 +0200 (CEST) Date: Tue, 18 Aug 2020 23:34:53 +0200 From: Pavel Machek To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Dan Carpenter , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: Re: [PATCH 4.19 073/168] media: firewire: Using uninitialized values in node_probe() Message-ID: <20200818213453.GB25182@amd> References: <20200817143733.692105228@linuxfoundation.org> <20200817143737.355562192@linuxfoundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="pvezYHf7grwyp3Bc" Content-Disposition: inline In-Reply-To: <20200817143737.355562192@linuxfoundation.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --pvezYHf7grwyp3Bc Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > From: Dan Carpenter >=20 > [ Upstream commit 2505a210fc126599013aec2be741df20aaacc490 ] >=20 > If fw_csr_string() returns -ENOENT, then "name" is uninitialized. So > then the "strlen(model_names[i]) <=3D name_len" is true because strlen() > is unsigned and -ENOENT is type promoted to a very high positive value. > Then the "strncmp(name, model_names[i], name_len)" uses uninitialized > data because "name" is uninitialized. This causes memory leak, AFAICT. Signed-off-by: Pavel Machek (CIP) Best regards, Pavel diff --git a/drivers/media/firewire/firedtv-fw.c b/drivers/media/firewire/f= iredtv-fw.c index eaf94b817dbc..2ac9d24d3f0c 100644 --- a/drivers/media/firewire/firedtv-fw.c +++ b/drivers/media/firewire/firedtv-fw.c @@ -271,8 +271,10 @@ static int node_probe(struct fw_unit *unit, const stru= ct ieee1394_device_id *id) =20 name_len =3D fw_csr_string(unit->directory, CSR_MODEL, name, sizeof(name)); - if (name_len < 0) - return name_len; + if (name_len < 0) { + err =3D name_len; + goto fail_free; + } for (i =3D ARRAY_SIZE(model_names); --i; ) if (strlen(model_names[i]) <=3D name_len && strncmp(name, model_names[i], name_len) =3D=3D 0) --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --pvezYHf7grwyp3Bc Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAl88SX0ACgkQMOfwapXb+vI6YQCglanJAWy5M2+yqIDcVnaJjLnA cCcAnR5rfyY8Pk/j/uo1uVKXyK0zUtkw =XDJf -----END PGP SIGNATURE----- --pvezYHf7grwyp3Bc--