From patchwork Mon Sep 21 21:53:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Dewar X-Patchwork-Id: 11791171 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6D0AF6CA for ; Mon, 21 Sep 2020 21:54:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4731823A61 for ; Mon, 21 Sep 2020 21:54:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mQUGkUWQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727724AbgIUVyi (ORCPT ); Mon, 21 Sep 2020 17:54:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727321AbgIUVyi (ORCPT ); Mon, 21 Sep 2020 17:54:38 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC554C061755; Mon, 21 Sep 2020 14:54:37 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id m6so14589705wrn.0; Mon, 21 Sep 2020 14:54:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=PaPRo0XlQ3Tqwwdz0cCFZ//U/ydF76ExJKyjshRmBL8=; b=mQUGkUWQXgqJEx41Ikk5Hdh7OPWSBXJZuQRhZ573ys5Jn+iXZng7yrOfOJdle52rq6 WCjDXE+d0JTrgWfcWYzco+9iZy1HiqbWrJ1afABFQMAPIgn6g4sx4UNyWaLO6oTSeScI ysLB2YvjfZKPrk4aP+t1b+kZGbQpqlOPWQ0wC7RKH5mkTG6/wOhwgM4xs4jPkizGYByR eSP3tzX0t59A6+6wGR8cia4SHmqYuenVKkiTWttPHaqhQNnvGuCT69HGf+kzUsb7LVPq nFvJN+A0y6niiO9CDkISYt6BWMJc6H56DuZ92LRJXN6j9tI5y+3+Tk8eUygv0idkc2mn WyJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PaPRo0XlQ3Tqwwdz0cCFZ//U/ydF76ExJKyjshRmBL8=; b=Dra2w7q2blZWS7ZE8HhPHyB9GEwbbFgiFMs13lsV7ISHSDhjtAEbWvglQf9eGEoA8a OhDMBSJR2QisV9TtD1BWTrntSB9Rat8MvXkHVYLnVIyYj0ZWBS5tLqzQYUsRlbAwOhxZ Cd4UAmjrWlPhRuI4yKxWicJdwZGcyRvco+Op0YVL0t3so3ULXQv9VGQyIbI3aX5/hnlc HTJLsRiAPFk2ng3NW86Osap5PdJmtNnszU3XQNmg6Z5wEyFOrMtAK2Pyek+rSNdoLYEw CNxzlBfC2EfeJkw+mLpcrk6Rr46h8zS5FOcgJ4AgMDlpG6ttIvY4XhU2ZdAUtkmEjm5M ZM0g== X-Gm-Message-State: AOAM531ldbeJj4lkm8Py+hIBJwEUpGUoS/PQWp8p/Ucz0ke5mB0JwJLr LO/EV+EcAmYCGJZoPYomYfYDGoqXOEsRegAV X-Google-Smtp-Source: ABdhPJwOrXQsNVkLMNJRRUIBZMRIVAg+clona6i8/KWzTK0i1abl4qfa8y4dIMttSgtqUWMSYcL6BQ== X-Received: by 2002:adf:dcd1:: with SMTP id x17mr1983338wrm.150.1600725276670; Mon, 21 Sep 2020 14:54:36 -0700 (PDT) Received: from localhost.localdomain (cpc83661-brig20-2-0-cust443.3-3.cable.virginm.net. [82.28.105.188]) by smtp.gmail.com with ESMTPSA id t124sm1282200wmg.31.2020.09.21.14.54.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 14:54:36 -0700 (PDT) From: Alex Dewar To: Mauro Carvalho Chehab , Sakari Ailus , Greg Kroah-Hartman , Alex Dewar , Linus Walleij , Dan Carpenter , Alan Cox , linux-media@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH RESEND 1/5] staging: media: atomisp: Fix error path in lm3554_probe() Date: Mon, 21 Sep 2020 22:53:51 +0100 Message-Id: <20200921215359.45003-2-alex.dewar90@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921215359.45003-1-alex.dewar90@gmail.com> References: <20200921215359.45003-1-alex.dewar90@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The error path for lm3554_probe() contains a number of bugs, including: * resource leaks * jumping to error labels out of sequence * not setting the return value appropriately Fix it up and give the labels more memorable names. This issue has existed since the code was originally contributed in commit a49d25364dfb ("staging/atomisp: Add support for the Intel IPU v2"), although the code was subsequently removed altogether and then reinstated with commit ad85094b293e ("Revert "media: staging: atomisp: Remove driver""). Addresses-Coverity: 1496802 ("Resource leaks") Fixes: a49d25364dfb ("staging/atomisp: Add support for the Intel IPU v2") Signed-off-by: Alex Dewar Reviewed-by: Dan Carpenter --- .../media/atomisp/i2c/atomisp-lm3554.c | 53 +++++++++++-------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/drivers/staging/media/atomisp/i2c/atomisp-lm3554.c b/drivers/staging/media/atomisp/i2c/atomisp-lm3554.c index 7ca7378b1859..cca10a4c2db0 100644 --- a/drivers/staging/media/atomisp/i2c/atomisp-lm3554.c +++ b/drivers/staging/media/atomisp/i2c/atomisp-lm3554.c @@ -833,7 +833,6 @@ static void *lm3554_platform_data_func(struct i2c_client *client) static int lm3554_probe(struct i2c_client *client) { - int err = 0; struct lm3554 *flash; unsigned int i; int ret; @@ -843,36 +842,38 @@ static int lm3554_probe(struct i2c_client *client) return -ENOMEM; flash->pdata = lm3554_platform_data_func(client); - if (IS_ERR(flash->pdata)) - return PTR_ERR(flash->pdata); + if (IS_ERR(flash->pdata)) { + ret = PTR_ERR(flash->pdata); + goto err_free_flash; + } v4l2_i2c_subdev_init(&flash->sd, client, &lm3554_ops); flash->sd.internal_ops = &lm3554_internal_ops; flash->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; flash->mode = ATOMISP_FLASH_MODE_OFF; flash->timeout = LM3554_MAX_TIMEOUT / LM3554_TIMEOUT_STEPSIZE - 1; - ret = - v4l2_ctrl_handler_init(&flash->ctrl_handler, - ARRAY_SIZE(lm3554_controls)); + ret = v4l2_ctrl_handler_init(&flash->ctrl_handler, + ARRAY_SIZE(lm3554_controls)); if (ret) { - dev_err(&client->dev, "error initialize a ctrl_handler.\n"); - goto fail2; + dev_err(&client->dev, "error initializing ctrl_handler"); + goto err_unregister_sd; } for (i = 0; i < ARRAY_SIZE(lm3554_controls); i++) v4l2_ctrl_new_custom(&flash->ctrl_handler, &lm3554_controls[i], NULL); - if (flash->ctrl_handler.error) { - dev_err(&client->dev, "ctrl_handler error.\n"); - goto fail2; + ret = flash->ctrl_handler.error; + if (ret) { + dev_err(&client->dev, "ctrl_handler error"); + goto err_free_ctrl_handler; } flash->sd.ctrl_handler = &flash->ctrl_handler; - err = media_entity_pads_init(&flash->sd.entity, 0, NULL); - if (err) { - dev_err(&client->dev, "error initialize a media entity.\n"); - goto fail1; + ret = media_entity_pads_init(&flash->sd.entity, 0, NULL); + if (ret) { + dev_err(&client->dev, "error initializing media entity"); + goto err_free_ctrl_handler; } flash->sd.entity.function = MEDIA_ENT_F_FLASH; @@ -881,20 +882,26 @@ static int lm3554_probe(struct i2c_client *client) timer_setup(&flash->flash_off_delay, lm3554_flash_off_delay, 0); - err = lm3554_gpio_init(client); - if (err) { + ret = lm3554_gpio_init(client); + if (ret) { dev_err(&client->dev, "gpio request/direction_output fail"); - goto fail2; + goto err_del_timer; } - return atomisp_register_i2c_module(&flash->sd, NULL, LED_FLASH); -fail2: + + ret = atomisp_register_i2c_module(&flash->sd, NULL, LED_FLASH); + if (!ret) + return 0; + +err_del_timer: + del_timer_sync(&flash->flash_off_delay); media_entity_cleanup(&flash->sd.entity); +err_free_ctrl_handler: v4l2_ctrl_handler_free(&flash->ctrl_handler); -fail1: +err_unregister_sd: v4l2_device_unregister_subdev(&flash->sd); +err_free_flash: kfree(flash); - - return err; + return ret; } static int lm3554_remove(struct i2c_client *client) From patchwork Mon Sep 21 21:53:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Dewar X-Patchwork-Id: 11791173 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E59A36CA for ; Mon, 21 Sep 2020 21:54:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C4A4D23A60 for ; Mon, 21 Sep 2020 21:54:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JcBjfG5v" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728251AbgIUVyz (ORCPT ); Mon, 21 Sep 2020 17:54:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726644AbgIUVyy (ORCPT ); Mon, 21 Sep 2020 17:54:54 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C9B0C061755; Mon, 21 Sep 2020 14:54:54 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id x23so1069046wmi.3; Mon, 21 Sep 2020 14:54:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=z3OVW099mqaL6VHBm46aQM/bYxWoZUj5xOibh7mUBIs=; b=JcBjfG5v++B4xBESN/8LbH5HNalPKqeId89ycgMpRgUPqeGjlMG6Iu2io64EAT6Ktv fEvL/NhH7whVyqJWfPv74OGREYFkr+ZggR+Jshmj/rHybWhgm1xI9AS2eI7SY7/wTsKy dySKayRDgjyKD2TQ0vfEBlXXRNt4kxjo9xeVWv14bBG3b86mOpc+4i1uDsoLMK3NATXZ zzTx2VXmusTKRP00RtFl2Q398z78oQzfVkMHb1GJe8eJJS2y/R/RyPr5eWTngB9sSezE eQgl3b9AxnY8nVuMmYz46vFLUSctejk0xWndkaBpOO6lo4QDRYPDiocnv7FJ7zc8Bbv/ xklg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=z3OVW099mqaL6VHBm46aQM/bYxWoZUj5xOibh7mUBIs=; b=hjtgpMr4NjLNkBy0sLqoiMRQrc73ot3ieATmzwBPXZGW7yXr+ttqRpe4avRRDHdV1E VmkEFTLiBTY9+8G1h7yBW3VyhvdivXhTkY2aU9x94RPPiwVPV4CkfH/Mx3GrbQi4DY7d ZwhrhH+CcF8GoDiiLsn8EeOroRGtk6LpOgqqLsGukzjJG6VAvHZVQAseDcdAVbj4W8FS ng8BGJooSttCEjIP0DvPtjrSdRWdyGe1+69nHwtzFBZtZ8FBvoJ/fH0uVyW6Hb2FActP BJ+mDwdPrzIUYQb+oYhvRASPeqZui4Vhyx1vlylTsOj4df33Cz+QwKiWJE6aDk3KE4fK JWFg== X-Gm-Message-State: AOAM530IovfeS84kUSAmegAKYA8ujQhxxuSJc7kbZ4AbviXdS0hTn7z1 8jmJacjwH8PmKH5nmXYf0sU= X-Google-Smtp-Source: ABdhPJxOnLPCBexCpj4xZ+md7j1W5MQ97wYWxB815btr+cdwiXrp8zS2kb+5jYiiPRgBxaWVjEL1uQ== X-Received: by 2002:a1c:dd45:: with SMTP id u66mr1276800wmg.117.1600725292950; Mon, 21 Sep 2020 14:54:52 -0700 (PDT) Received: from localhost.localdomain (cpc83661-brig20-2-0-cust443.3-3.cable.virginm.net. [82.28.105.188]) by smtp.gmail.com with ESMTPSA id t124sm1282200wmg.31.2020.09.21.14.54.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 14:54:52 -0700 (PDT) From: Alex Dewar To: Mauro Carvalho Chehab , Sakari Ailus , Greg Kroah-Hartman , Alex Dewar , Dan Carpenter , Linus Walleij , Alan Cox , linux-media@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH RESEND 2/5] staging: media: atomisp: Remove unhelpful info message Date: Mon, 21 Sep 2020 22:53:53 +0100 Message-Id: <20200921215359.45003-3-alex.dewar90@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921215359.45003-1-alex.dewar90@gmail.com> References: <20200921215359.45003-1-alex.dewar90@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org We don't really need to know that the LED pin reset successfully. Signed-off-by: Alex Dewar --- drivers/staging/media/atomisp/i2c/atomisp-lm3554.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/media/atomisp/i2c/atomisp-lm3554.c b/drivers/staging/media/atomisp/i2c/atomisp-lm3554.c index cca10a4c2db0..d78014847e67 100644 --- a/drivers/staging/media/atomisp/i2c/atomisp-lm3554.c +++ b/drivers/staging/media/atomisp/i2c/atomisp-lm3554.c @@ -771,7 +771,6 @@ static int lm3554_gpio_init(struct i2c_client *client) ret = gpiod_direction_output(pdata->gpio_reset, 0); if (ret < 0) return ret; - dev_info(&client->dev, "flash led reset successfully\n"); if (!pdata->gpio_strobe) return -EINVAL; From patchwork Mon Sep 21 21:53:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Dewar X-Patchwork-Id: 11791175 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B5CA46CA for ; Mon, 21 Sep 2020 21:55:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9595123A65 for ; Mon, 21 Sep 2020 21:55:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HFH4glgr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728317AbgIUVzS (ORCPT ); Mon, 21 Sep 2020 17:55:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726497AbgIUVzS (ORCPT ); Mon, 21 Sep 2020 17:55:18 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4610C061755; Mon, 21 Sep 2020 14:55:17 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id g4so14557127wrs.5; Mon, 21 Sep 2020 14:55:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=msyTyBuqg+S9lSfyJBnZ2ellRZt6dmdc0yChx+UPxKo=; b=HFH4glgr8zU1oXfraHmc2FYWvCMnmC+sxpTG200tp8l4hHLtC2gqfDvnKD0jX5zr2A U5PhRmCeevGoZN4iO/TYhjFAeVRVZuRkZV1ZzuWxTULU9tmZiWKYwonAESXP4h8Q2Qnl zSv+jP4GyUUOh5sVzYtwl310G0yLz95w1/stZ0caQqlsdpwhdOrFYK2FnIyKgjsozSg9 ydKfCEzapSddN3N1jjAv3t+5HuJww9ZdL6qHb7NwUSc2y7jGzORTBRWQZMxPnt+Gk7WK L3ToJvGi3Jf2Bt0UrBVMuEcv+M0SlE85eYBk0AcyppjmfhH31CfTvNiLCvi77k8ClwCT F6uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=msyTyBuqg+S9lSfyJBnZ2ellRZt6dmdc0yChx+UPxKo=; b=sykyjqugr1bLr3QaM2J2+MPHtWKPkuYH/O5F3CFvx6fsremOsBZOMP7VtU+xFGWfh7 3o6KIa7Nvn1esKS2lvbR34qzVezmCpWpwELYVKQkJ9acWRBwxMAnKPSPfHxhzSw8dnZQ Rur8NwNyMXVrrwX4U4G2ORdtxk7MXCLkhGQgNRyGQJqWSb5p2MddXFTgm7zRcv7MuwYA nv84Ur1xW0MLsFP6KeSjLdjwdXLravAFxTkiPM9U83AGtSrHqqqnyKdTQNKQeWsP26nM hqaLEtNfJTaAIC5re5F9vzXgxjRHeuUNc2QdneO4mAryvjWyNisw49gjKqPH4GlLMsd9 ibrQ== X-Gm-Message-State: AOAM533Va8De6QN4OWRZ6ksUCI8avm1tQhyBd5KXo0ZqRDxr52Iw3Hch hAtCirLorcnMMe1TZiKiiXQ= X-Google-Smtp-Source: ABdhPJzEYvjLv/YYaExP7WY18BaVye8dfGy+D2i4BAk8NEq+a3xw5G6BgT2nLo5IEKUwO4Sea96uEw== X-Received: by 2002:adf:e7c4:: with SMTP id e4mr1786175wrn.113.1600725316622; Mon, 21 Sep 2020 14:55:16 -0700 (PDT) Received: from localhost.localdomain (cpc83661-brig20-2-0-cust443.3-3.cable.virginm.net. [82.28.105.188]) by smtp.gmail.com with ESMTPSA id t124sm1282200wmg.31.2020.09.21.14.55.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 14:55:16 -0700 (PDT) From: Alex Dewar To: Mauro Carvalho Chehab , Sakari Ailus , Greg Kroah-Hartman , Alex Dewar , Dan Carpenter , Linus Walleij , Alan Cox , linux-media@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH RESEND 3/5] staging: media: atomisp: Don't do unnecessary zeroing of memory Date: Mon, 21 Sep 2020 22:53:55 +0100 Message-Id: <20200921215359.45003-4-alex.dewar90@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921215359.45003-1-alex.dewar90@gmail.com> References: <20200921215359.45003-1-alex.dewar90@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org In a few places in pci/sh_css_params.c, memset is used to zero memory immediately before it is freed. As none of these structs appear to contain sensitive information, just remove the calls to memset. Suggested-by: Dan Carpenter Signed-off-by: Alex Dewar --- drivers/staging/media/atomisp/pci/sh_css_params.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/sh_css_params.c b/drivers/staging/media/atomisp/pci/sh_css_params.c index 2c67c23b3700..24fc497bd491 100644 --- a/drivers/staging/media/atomisp/pci/sh_css_params.c +++ b/drivers/staging/media/atomisp/pci/sh_css_params.c @@ -4378,7 +4378,6 @@ ia_css_3a_statistics_free(struct ia_css_3a_statistics *me) if (me) { kvfree(me->rgby_data); kvfree(me->data); - memset(me, 0, sizeof(struct ia_css_3a_statistics)); kvfree(me); } } @@ -4417,7 +4416,6 @@ ia_css_dvs_statistics_free(struct ia_css_dvs_statistics *me) if (me) { kvfree(me->hor_proj); kvfree(me->ver_proj); - memset(me, 0, sizeof(struct ia_css_dvs_statistics)); kvfree(me); } } @@ -4459,7 +4457,6 @@ ia_css_dvs_coefficients_free(struct ia_css_dvs_coefficients *me) if (me) { kvfree(me->hor_coefs); kvfree(me->ver_coefs); - memset(me, 0, sizeof(struct ia_css_dvs_coefficients)); kvfree(me); } } @@ -4551,7 +4548,6 @@ ia_css_dvs2_statistics_free(struct ia_css_dvs2_statistics *me) kvfree(me->ver_prod.odd_imag); kvfree(me->ver_prod.even_real); kvfree(me->ver_prod.even_imag); - memset(me, 0, sizeof(struct ia_css_dvs2_statistics)); kvfree(me); } } @@ -4635,7 +4631,6 @@ ia_css_dvs2_coefficients_free(struct ia_css_dvs2_coefficients *me) kvfree(me->ver_coefs.odd_imag); kvfree(me->ver_coefs.even_real); kvfree(me->ver_coefs.even_imag); - memset(me, 0, sizeof(struct ia_css_dvs2_coefficients)); kvfree(me); } } @@ -4710,7 +4705,6 @@ ia_css_dvs2_6axis_config_free(struct ia_css_dvs_6axis_config *dvs_6axis_config) kvfree(dvs_6axis_config->ycoords_y); kvfree(dvs_6axis_config->xcoords_uv); kvfree(dvs_6axis_config->ycoords_uv); - memset(dvs_6axis_config, 0, sizeof(struct ia_css_dvs_6axis_config)); kvfree(dvs_6axis_config); } } From patchwork Mon Sep 21 21:53:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Dewar X-Patchwork-Id: 11791177 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A33856CA for ; Mon, 21 Sep 2020 21:55:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 818D52388B for ; Mon, 21 Sep 2020 21:55:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PINJawvQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728518AbgIUVzk (ORCPT ); Mon, 21 Sep 2020 17:55:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726497AbgIUVzh (ORCPT ); Mon, 21 Sep 2020 17:55:37 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2417BC061755; Mon, 21 Sep 2020 14:55:37 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id m6so14593521wrn.0; Mon, 21 Sep 2020 14:55:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=t6IkKnXa5tIfj0pEtiHch/id+y7KfUWCLs3pBM4+7Bw=; b=PINJawvQ9e9dquFTGr3zZx+5fm9L2BiwpAHxL74wVdUTWTQ89n3Kvz10/lWMYxqiY2 xBYnD7L8FxZ7/R4caI6NUzLRu/mjXbSxlQ72Hg7c9skBQon3JaNsZZ/dZ+iUT7oUPUae P4zBqty9tOvDZEI/SBo72+1RWJPm9O/4e1ijPOi/4NA2qPOCP1C1B9VMaaLMzLo4nMFp 6l/zp3Nl6a4SrEDiRFVU4FKXHIOl0+CeAbivhoM38DO6prMPg0bVyjEJpxCIfai6RV6L LBwSDQNcgoa/J4ukll6YHth/9asvcPFtlOsUUa42kCDDOtBAJCqq+8exPpT/Egr2rBQH pU1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=t6IkKnXa5tIfj0pEtiHch/id+y7KfUWCLs3pBM4+7Bw=; b=TDSbpRMTeoMlhyKlet9Byoy04bCSadOgzJzv3N+yN2L0HAXHJ9FCEPzQR/sELIkc6p oKgcqtNqn3YYAjb2XwbrmNHzYSXgfyFDlDdFdxZF7VpnEiijuSSS1VzKgbCASbbqe0Yt 9g3aGemwTV2kwkQzFio5nb2piJxVkX6eXOfxq22up8LAL4qZkdZdAu/BbvsZn0PjWCXA sAFQl8IHGP1XjlJk/hKWQgar2rJcLyjk4k5HKJY0mnxZdvyLjeUqI62m4TxJRQyGXopm 36Gwct0GHrmBPy5br7DfFfXX4AW590P684E9hdKw/1KonYa5XC3MzEpBTiga8ileqn83 H84Q== X-Gm-Message-State: AOAM5336m0AWV+9MVNz3rcRXTUuYSLEHTYh6J9N2QlRP5JlSippjxANR gmz7EpN5M7LXMxUwS6/YUfw= X-Google-Smtp-Source: ABdhPJwWDNjkSOFG5QNhQ+EcOhRxbhHygXIASP2+2Z2iIZMH8zrj0Y480HY7ngQKNF4hGEBQ7ZqT6A== X-Received: by 2002:adf:ef4f:: with SMTP id c15mr1994655wrp.390.1600725335846; Mon, 21 Sep 2020 14:55:35 -0700 (PDT) Received: from localhost.localdomain (cpc83661-brig20-2-0-cust443.3-3.cable.virginm.net. [82.28.105.188]) by smtp.gmail.com with ESMTPSA id t124sm1282200wmg.31.2020.09.21.14.55.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 14:55:35 -0700 (PDT) From: Alex Dewar To: Mauro Carvalho Chehab , Sakari Ailus , Greg Kroah-Hartman , Alex Dewar , Linus Walleij , Dan Carpenter , Alan Cox , linux-media@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH RESEND 4/5] staging: media: atomisp: Don't abort on error in module exit path Date: Mon, 21 Sep 2020 22:53:57 +0100 Message-Id: <20200921215359.45003-5-alex.dewar90@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921215359.45003-1-alex.dewar90@gmail.com> References: <20200921215359.45003-1-alex.dewar90@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The function lm3554_remove() checks for the return code for lm3554_gpio_uninit() even though this is on the exit path and exits the function, leaving the variable flash unfreed. Instead, print a warning and free flash unconditionally. Signed-off-by: Alex Dewar --- .../staging/media/atomisp/i2c/atomisp-lm3554.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/staging/media/atomisp/i2c/atomisp-lm3554.c b/drivers/staging/media/atomisp/i2c/atomisp-lm3554.c index d78014847e67..d446ee8e93db 100644 --- a/drivers/staging/media/atomisp/i2c/atomisp-lm3554.c +++ b/drivers/staging/media/atomisp/i2c/atomisp-lm3554.c @@ -782,7 +782,7 @@ static int lm3554_gpio_init(struct i2c_client *client) return 0; } -static int lm3554_gpio_uninit(struct i2c_client *client) +static void lm3554_gpio_uninit(struct i2c_client *client) { struct v4l2_subdev *sd = i2c_get_clientdata(client); struct lm3554 *flash = to_lm3554(sd); @@ -791,13 +791,13 @@ static int lm3554_gpio_uninit(struct i2c_client *client) ret = gpiod_direction_output(pdata->gpio_strobe, 0); if (ret < 0) - return ret; + dev_err(&client->dev, + "gpio request/direction_output fail for gpio_strobe"); ret = gpiod_direction_output(pdata->gpio_reset, 0); if (ret < 0) - return ret; - - return 0; + dev_err(&client->dev, + "gpio request/direction_output fail for gpio_reset"); } static void *lm3554_platform_data_func(struct i2c_client *client) @@ -907,7 +907,6 @@ static int lm3554_remove(struct i2c_client *client) { struct v4l2_subdev *sd = i2c_get_clientdata(client); struct lm3554 *flash = to_lm3554(sd); - int ret; media_entity_cleanup(&flash->sd.entity); v4l2_ctrl_handler_free(&flash->ctrl_handler); @@ -917,16 +916,11 @@ static int lm3554_remove(struct i2c_client *client) del_timer_sync(&flash->flash_off_delay); - ret = lm3554_gpio_uninit(client); - if (ret < 0) - goto fail; + lm3554_gpio_uninit(client); kfree(flash); return 0; -fail: - dev_err(&client->dev, "gpio request/direction_output fail"); - return ret; } static const struct dev_pm_ops lm3554_pm_ops = { From patchwork Mon Sep 21 21:53:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Dewar X-Patchwork-Id: 11791179 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 77D3559D for ; Mon, 21 Sep 2020 21:56:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4EAA523A69 for ; Mon, 21 Sep 2020 21:56:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="sGK1TOhe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728256AbgIUV43 (ORCPT ); Mon, 21 Sep 2020 17:56:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726452AbgIUV42 (ORCPT ); Mon, 21 Sep 2020 17:56:28 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72249C061755; Mon, 21 Sep 2020 14:56:28 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id z9so1068342wmk.1; Mon, 21 Sep 2020 14:56:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=jWDoQRsOrsy1ykH1KPmy1+vKMaQziG+C5VVRexrwgCo=; b=sGK1TOheGHfrAsQ3ERBM3fntXI8KjxRS1dFamE/qx9Cf2nMJnjTDTEOutmjZHzCVx8 aiSrx+nR739BMnCTbNoJxqC8GgyGvHt4KZkEkzq+f8QojUUtfU0H2H7UXwEanK7tR/M/ +q7Xxy1H5j9evBS7jrajpIhV1iYX6t7pCjFGArV0a81le7LqZjIaddv2Ixj1NcWOHUc0 ozQg2fJYw+fPsD/N53cP6t4Bbgptks+dlyZjmMy2L+t0rdgU+uAJZYL8ec/JVqDylfUE NFEIPU66DpA5fwvdB2vgyvAZF3FWyKJKLIZ25p+fqWWQbwi9G1OPat1SK137ybYwvGWG hBig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jWDoQRsOrsy1ykH1KPmy1+vKMaQziG+C5VVRexrwgCo=; b=i2S1fwz2vam5ou/NcPhwtlkzOXPb0U0O6vyOUQtAyeZtMCZQUSjJE4MChooDfYGNaW DLw2YG1oqwNarSIA4O3rafzlfTrAuoJSZm31fwkTycAlQTp2wa0s/mZiF486ysuaeFmi uUOMXyVIQqogxkOg/FpeGihobDULWAsL+45mvPIuc9FmlgbKhyUz7M8ymT6WFb7dyYuC 6VsGiD0Pxf6Wn+QqyVY4DLyBf5sIOBU/BhfiqZiF2kLAcCmusf6KZNIywHAc5+nQSYwj y4Kxy6ZyGS4+V6zGmdwWutjouOqe1h3csMQHze69UFmu9ki4tuD4mwklR38j2LVL03iq hpnA== X-Gm-Message-State: AOAM530tkzK2R0deXktndJJ3r6vKWhRs+4eUfwWMQek+tyy3mtj7kVJJ aceymAzLh4oxYQW8xPTFfrg= X-Google-Smtp-Source: ABdhPJxcwQlOBHjwWBu+fwCPOpLzt1KKBak4JbdBtQskwnLJci0jZFHKRyBIFeWRYF40GmkYeyqiWQ== X-Received: by 2002:a1c:bcd6:: with SMTP id m205mr1337357wmf.68.1600725387086; Mon, 21 Sep 2020 14:56:27 -0700 (PDT) Received: from localhost.localdomain (cpc83661-brig20-2-0-cust443.3-3.cable.virginm.net. [82.28.105.188]) by smtp.gmail.com with ESMTPSA id t124sm1282200wmg.31.2020.09.21.14.56.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 14:56:26 -0700 (PDT) From: Alex Dewar To: Mauro Carvalho Chehab , Sakari Ailus , Greg Kroah-Hartman , Alex Dewar , Dan Carpenter , Linus Walleij , Andy Shevchenko , Alan Cox , linux-media@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH RESEND 5/5] staging: media: atomisp: Fix bool-related style issues Date: Mon, 21 Sep 2020 22:53:59 +0100 Message-Id: <20200921215359.45003-6-alex.dewar90@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921215359.45003-1-alex.dewar90@gmail.com> References: <20200921215359.45003-1-alex.dewar90@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Address the following issues: * unnecessary comparison to true/false * use of 0/1 instead of bool values * unnecessary conversion to bool These were fixed using the following Coccinelle scripts: * scripts/coccinelle/misc/bool{init,conv,return}.cocci Build-tested with allmodconfig. Signed-off-by: Alex Dewar --- .../staging/media/atomisp/pci/atomisp_cmd.c | 5 ++--- drivers/staging/media/atomisp/pci/sh_css.c | 20 +++++++++---------- .../media/atomisp/pci/sh_css_firmware.c | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp_cmd.c index 9f25f13c3255..592ea990d4ca 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c +++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c @@ -654,8 +654,7 @@ bool atomisp_buffers_queued(struct atomisp_sub_device *asd) return asd->video_out_capture.buffers_in_css || asd->video_out_vf.buffers_in_css || asd->video_out_preview.buffers_in_css || - asd->video_out_video_capture.buffers_in_css ? - true : false; + asd->video_out_video_capture.buffers_in_css; } /* ISP2401 */ @@ -6549,7 +6548,7 @@ int atomisp_enable_dz_capt_pipe(struct atomisp_sub_device *asd, if (!enable) return -EINVAL; - value = *enable > 0 ? true : false; + value = *enable > 0; atomisp_en_dz_capt_pipe(asd, value); diff --git a/drivers/staging/media/atomisp/pci/sh_css.c b/drivers/staging/media/atomisp/pci/sh_css.c index 3e9366b20af0..c50b5fba7b86 100644 --- a/drivers/staging/media/atomisp/pci/sh_css.c +++ b/drivers/staging/media/atomisp/pci/sh_css.c @@ -3681,7 +3681,7 @@ static int create_host_video_pipeline(struct ia_css_pipe *pipe) struct ia_css_frame *tmp_out_frame = NULL; for (i = 0; i < num_yuv_scaler; i++) { - if (is_output_stage[i] == true) { + if (is_output_stage[i]) { tmp_out_frame = out_frame; } else { tmp_out_frame = NULL; @@ -4421,7 +4421,7 @@ ia_css_pipe_dequeue_buffer(struct ia_css_pipe *pipe, case IA_CSS_BUFFER_TYPE_INPUT_FRAME: case IA_CSS_BUFFER_TYPE_OUTPUT_FRAME: case IA_CSS_BUFFER_TYPE_SEC_OUTPUT_FRAME: - if ((pipe) && (pipe->stop_requested == true)) { + if (pipe && pipe->stop_requested) { #if !defined(ISP2401) /* free mipi frames only for old input system * for 2401 it is done in ia_css_stream_destroy call @@ -4782,7 +4782,7 @@ sh_css_pipe_start(struct ia_css_stream *stream) { pipe_id = pipe->mode; - if (stream->started == true) + if (stream->started) { IA_CSS_WARNING("Cannot start stream that is already started"); IA_CSS_LEAVE_ERR(err); @@ -5919,7 +5919,7 @@ static bool need_capture_pp( if (IS_ISP2401) { /* ldc and capture_pp are not supported in the same pipeline */ - if (need_capt_ldc(pipe) == true) + if (need_capt_ldc(pipe)) return false; } @@ -6135,8 +6135,8 @@ static int load_primary_binaries( IA_CSS_LEAVE_ERR_PRIVATE(err); return err; } - need_pp = 0; - need_ldc = 0; + need_pp = false; + need_ldc = false; } /* we build up the pipeline starting at the end */ @@ -9496,10 +9496,10 @@ ia_css_stream_create(const struct ia_css_stream_config *stream_config, IA_CSS_PIPE_MODE_VIDEO, false); acc_pipe = find_pipe(pipes, num_pipes, IA_CSS_PIPE_MODE_ACC, false); - if (acc_pipe && num_pipes == 2 && curr_stream->cont_capt == true) + if (acc_pipe && num_pipes == 2 && curr_stream->cont_capt) curr_stream->cont_capt = false; /* preview + QoS case will not need cont_capt switch */ - if (curr_stream->cont_capt == true) { + if (curr_stream->cont_capt) { capture_pipe = find_pipe(pipes, num_pipes, IA_CSS_PIPE_MODE_CAPTURE, false); if (!capture_pipe) { @@ -9521,7 +9521,7 @@ ia_css_stream_create(const struct ia_css_stream_config *stream_config, preview_pipe->pipe_settings.preview.copy_pipe = copy_pipe; copy_pipe->stream = curr_stream; } - if (preview_pipe && (curr_stream->cont_capt == true)) { + if (preview_pipe && curr_stream->cont_capt) { preview_pipe->pipe_settings.preview.capture_pipe = capture_pipe; } if (video_pipe && !video_pipe->pipe_settings.video.copy_pipe) { @@ -9532,7 +9532,7 @@ ia_css_stream_create(const struct ia_css_stream_config *stream_config, video_pipe->pipe_settings.video.copy_pipe = copy_pipe; copy_pipe->stream = curr_stream; } - if (video_pipe && (curr_stream->cont_capt == true)) { + if (video_pipe && curr_stream->cont_capt) { video_pipe->pipe_settings.video.capture_pipe = capture_pipe; } if (preview_pipe && acc_pipe) { diff --git a/drivers/staging/media/atomisp/pci/sh_css_firmware.c b/drivers/staging/media/atomisp/pci/sh_css_firmware.c index 244c7c7780a3..db25e39bea88 100644 --- a/drivers/staging/media/atomisp/pci/sh_css_firmware.c +++ b/drivers/staging/media/atomisp/pci/sh_css_firmware.c @@ -207,7 +207,7 @@ sh_css_check_firmware_version(struct device *dev, const char *fw_data) } /* For now, let's just accept a wrong version, even if wrong */ - return 0; + return false; } static const char * const fw_type_name[] = {