Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp905155rdg; Fri, 11 Aug 2023 04:00:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF/3kiE8flx5sta35qODE4OR2A0NEA0/bycgOiSYHg1pslJ1nw8xs9eUcSv/99YDIilZsw7 X-Received: by 2002:a05:6808:2a79:b0:3a3:6576:f31b with SMTP id fu25-20020a0568082a7900b003a36576f31bmr1571027oib.36.1691751643765; Fri, 11 Aug 2023 04:00:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691751643; cv=none; d=google.com; s=arc-20160816; b=xPvY6tmFEtcZ54DC5Tt6cFh7Dkh1OND7yI2hffAOa91B9DTBKLgxbcF/hzla6YeiSQ 1V58T0ptnivdD9Okm143A4nVIZCb+CkwgYigDype5+YQD5+vxHxkBJdd+PCHYclDKjUO riSpk+qZ3tY0wCGwiJ6E9gv5A2CkrBlevlvZHpDdpgdyfgtp+Rp9vjl6lMLziYWEI7vo apiP1ylUlx5RaCKLjpol3L04mfrrLWl3LM3Z9EUmdcENit3bElFmg9uA4NWfSYpy0iLN We0KaRWfh+ZAaA7UrPmuihonbr0Rcim/2WdCb3fUcuIr8VTeHd8u5se1KlJQfswpFmBp lc9Q== 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 :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=vjats05GdKzYlh+X7ECQ3mchfPO/J7vIMDKp9Pec2dg=; fh=XZbGzrxy9sHFmO+s4UEbuGujcU2Ima2aW9OIjLKq0fE=; b=MtkzbbVCBBZrV3fjZIwZXITrpVjv5FPrrl92EAes0ljUkrX0OU14PRxdMe5nunsnui blooYu8FHTUGT0KMz8aZhtkZiD2yHN8FSY2NC7/ohkq0PWMVS+DwN85lrh71ZT6Pxhya kZWwQHnm3gIvlQas+hWKozYze0Dtfb3trjA0eWDZC+MxrPOna7qyjt8xG4BTZj/RBMIu RlpnfPs68VJD1/CbMWrSEGIsvgAK9yvh9c3sKDRhKmJe1yor7dKItOSRUuBZbsk6H5Ev qJJLqJ3lgjbIZipXmCWq6wvm9SmdV6vBChWMcqAek422NYDp7j11yKL5GbBYhlgkeT70 RklA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j2-20020a63e742000000b00564b1002ad9si3090755pgk.772.2023.08.11.04.00.31; Fri, 11 Aug 2023 04:00:43 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235419AbjHKJ62 (ORCPT + 99 others); Fri, 11 Aug 2023 05:58:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235244AbjHKJ6T (ORCPT ); Fri, 11 Aug 2023 05:58:19 -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 AD72E30D2; Fri, 11 Aug 2023 02:58:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4280166D49; Fri, 11 Aug 2023 09:58:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67194C433CD; Fri, 11 Aug 2023 09:58:15 +0000 (UTC) Message-ID: <87b8b82a-f9ff-f539-be46-a2ba8714395b@xs4all.nl> Date: Fri, 11 Aug 2023 11:58:14 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH] media: usb: go7007: Fix warning: passing freed memory 'fw' Content-Language: en-US, nl To: Madhumitha Prabakaran , mchehab@kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: skhan@linuxfoundation.org, ivan.orlov0322@gmail.com References: <20230809010026.GA4770@madhu-kernel> From: Hans Verkuil In-Reply-To: <20230809010026.GA4770@madhu-kernel> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,NICE_REPLY_A,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS 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 09/08/2023 03:00, Madhumitha Prabakaran wrote: > Fix smatch warning - go7007_loader_probe() warn: passing freed memory 'fw' > > The 'fw' pointer is released using release_firmware(fw) and then being used > again in another request_firmware() call without being reassigned to a new > memory allocation. To resolve it, use separate variables for each request. Hmm, I don't get this smatch warning. And it doesn't appear to be an actual bug either, so that warning would be a false positive. I wonder if you tested with an older smatch version? Regards, Hans > > Signed-off-by: Madhumitha Prabakaran > --- > drivers/media/usb/go7007/go7007-loader.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/drivers/media/usb/go7007/go7007-loader.c b/drivers/media/usb/go7007/go7007-loader.c > index 243aa0ad074c..5f5c425f4d45 100644 > --- a/drivers/media/usb/go7007/go7007-loader.c > +++ b/drivers/media/usb/go7007/go7007-loader.c > @@ -35,7 +35,7 @@ static int go7007_loader_probe(struct usb_interface *interface, > const struct usb_device_id *id) > { > struct usb_device *usbdev; > - const struct firmware *fw; > + const struct firmware *fw_1, *fw_2; > u16 vendor, product; > const char *fw1, *fw2; > int ret; > @@ -67,13 +67,13 @@ static int go7007_loader_probe(struct usb_interface *interface, > > dev_info(&interface->dev, "loading firmware %s\n", fw1); > > - if (request_firmware(&fw, fw1, &usbdev->dev)) { > + if (request_firmware(&fw_1, fw1, &usbdev->dev)) { > dev_err(&interface->dev, > "unable to load firmware from file \"%s\"\n", fw1); > goto failed2; > } > - ret = cypress_load_firmware(usbdev, fw, CYPRESS_FX2); > - release_firmware(fw); > + ret = cypress_load_firmware(usbdev, fw_1, CYPRESS_FX2); > + release_firmware(fw_1); > if (0 != ret) { > dev_err(&interface->dev, "loader download failed\n"); > goto failed2; > @@ -82,13 +82,13 @@ static int go7007_loader_probe(struct usb_interface *interface, > if (fw2 == NULL) > return 0; > > - if (request_firmware(&fw, fw2, &usbdev->dev)) { > + if (request_firmware(&fw_2, fw2, &usbdev->dev)) { > dev_err(&interface->dev, > "unable to load firmware from file \"%s\"\n", fw2); > goto failed2; > } > - ret = cypress_load_firmware(usbdev, fw, CYPRESS_FX2); > - release_firmware(fw); > + ret = cypress_load_firmware(usbdev, fw_2, CYPRESS_FX2); > + release_firmware(fw_2); > if (0 != ret) { > dev_err(&interface->dev, "firmware download failed\n"); > goto failed2;