From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D014FC433FE for ; Fri, 4 Dec 2020 02:57:51 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7F922224D4 for ; Fri, 4 Dec 2020 02:57:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7F922224D4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Date:To:From: Subject:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=jDF4tvpI2oD+pcqnicN7KPaeCfoFUwHzP9E1YuXJYuc=; b=nyIMDMjRplh3uC8D6ua3VRrAt BfLJjSVZvnjKahLAWmEdim30VtFvdNFCsV8LHpCheXbLJ1fUeOcNyWV6yvQXE0D4zuoV18DljmxA/ KOJAdqt7Pxgtj7wbXFZqUZM/nLdKhmt7xBck0muGAWUjmbBYN6rSHoXp3QCs80ELZj1+Ta4gfVbjd ybgc4Y3vX52EGtONHKU/0DWGEWUXiccJYyimBn8o1gkGKZRPpbp/z9t3Zf2ei+ESxzfPr5/32cTVj PUtnRkLFe6qjoq4e8FbYH1+XKIuLTSlCVRKIOvgBrcSHkUC9eCTLntNVWHlHXGL8/Z9ae9CLHM4yh PL0BxE4FA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kl1Gj-0001f2-V5; Fri, 04 Dec 2020 02:56:25 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kl1Gi-0001e2-0b; Fri, 04 Dec 2020 02:56:25 +0000 X-UUID: e97a1d4a12644cddacede95abc51e41d-20201203 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:MIME-Version:Content-Type:References:In-Reply-To:Date:CC:To:From:Subject:Message-ID; bh=HFCQ5ohxF0aLV8mEa0u/JoA63IqNHij1i7SP2mutPLU=; b=Opazqa7xIWUWg4IjFor2cnt6TLiWWwNsQiz62cT1opLdc1Gsrk0OH57dLd5bt6znyWqGFHrrik355TfT6HJ52STU7gtTOBd8vnDDuGXOMEjVQ93XZ8Nnf6RunUcW2UqHZvsdd0ULLLpfteDvaVIlWELgQ5hMO9+Kea+AOiorlfM=; X-UUID: e97a1d4a12644cddacede95abc51e41d-20201203 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 913233119; Thu, 03 Dec 2020 18:56:17 -0800 Received: from MTKMBS31N1.mediatek.inc (172.27.4.69) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 3 Dec 2020 18:46:17 -0800 Received: from MTKCAS36.mediatek.inc (172.27.4.186) by MTKMBS31N1.mediatek.inc (172.27.4.69) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 4 Dec 2020 10:46:07 +0800 Received: from [10.17.3.153] (10.17.3.153) by MTKCAS36.mediatek.inc (172.27.4.170) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 4 Dec 2020 10:46:05 +0800 Message-ID: <1607049966.4733.189.camel@mhfsdcap03> Subject: Re: media: i2c: add OV02A10 image sensor driver From: Dongchun Zhu To: Andy Shevchenko Date: Fri, 4 Dec 2020 10:46:06 +0800 In-Reply-To: References: <9af089ea-2532-68ac-5d22-97a669ccec91@canonical.com> X-Mailer: Evolution 3.10.4-0ubuntu2 MIME-Version: 1.0 X-TM-SNTS-SMTP: B9D516F0823BDF1801AF36AFAB9F17DA8860BE715019026247D88428AAF69A9E2000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201203_215624_271260_F928E156 X-CRM114-Status: GOOD ( 22.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mauro Carvalho Chehab , "linux-kernel@vger.kernel.org" , tfiga@google.com, sj.huang@mediatek.com, "moderated list:ARM/Mediatek SoC support" , dongchun.zhu@mediatek.com, Sakari Ailus , Matthias Brugger , Colin Ian King , Andy Shevchenko , "linux-arm-kernel@lists.infradead.org" , linux-media Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Andy, On Thu, 2020-12-03 at 20:10 +0200, Andy Shevchenko wrote: > On Thu, Dec 3, 2020 at 8:03 PM Colin Ian King wrote: > > > Static analysis on linux-next with Coverity has detected an issue with > > the following commit: > > If you want to fix it properly, see my comments below... > > > 529 static int ov02a10_s_stream(struct v4l2_subdev *sd, int on) > > 530 { > > 531 struct ov02a10 *ov02a10 = to_ov02a10(sd); > > 532 struct i2c_client *client = > > v4l2_get_subdevdata(&ov02a10->subdev); > > > > 1. var_decl: Declaring variable ret without initializer. > > > > 533 int ret; > > 534 > > 535 mutex_lock(&ov02a10->mutex); > > 536 > > > > 2. Condition ov02a10->streaming == on, taking true branch. > > > > 537 if (ov02a10->streaming == on) > > > > 3. Jumping to label unlock_and_return. > > > > 538 goto unlock_and_return; > > 539 > > 540 if (on) { > > 541 ret = pm_runtime_get_sync(&client->dev); > > 542 if (ret < 0) { > > > 543 pm_runtime_put_noidle(&client->dev); > > 544 goto unlock_and_return; > > Instead of two above: >From the document, pm_runtime_put_noidle is to decrease the runtime PM usage counter of a device unless it is 0 already; while pm_runtime_put would additionally run pm_request_idle to turn off the power if usage counter is zero. So here maybe we can really use pm_runtime_put instead of pm_runtime_put_noidle, although it seems that 'pm_runtime_get_sync' and 'pm_runtime_put_noidle' often appear in pairs. > goto err_rpm_put; > > > 545 } > > 546 > > 547 ret = __ov02a10_start_stream(ov02a10); > > 548 if (ret) { > > 549 __ov02a10_stop_stream(ov02a10); > > 550 ov02a10->streaming = !on; > > 551 goto err_rpm_put; > > 552 } > > 553 } else { > > 554 __ov02a10_stop_stream(ov02a10); > > 555 pm_runtime_put(&client->dev); > > 556 } > > 557 > > 558 ov02a10->streaming = on; > > (1) > > > 559 mutex_unlock(&ov02a10->mutex); > > 560 > > 561 return 0; > > 562 > > 563 err_rpm_put: > > 564 pm_runtime_put(&client->dev); > > > 565 unlock_and_return: > > Should be moved to (1). > > > 566 mutex_unlock(&ov02a10->mutex); > > 567 > > > > Uninitialized scalar variable (UNINIT) > > 4. uninit_use: Using uninitialized value ret. > > > > 568 return ret; > > 569 } > > > > Variable ret has not been initialized, so the error return value is a > > garbage value. It should be initialized with some appropriate negative > > error code, or ret could be removed and the return should return a > > literal value of a error code. > > > > I was unsure what value is appropriate to fix this, so instead I'm > > reporting this issue. > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel