From patchwork Fri Oct 6 10:08:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13411241 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BCBCE92FFE for ; Fri, 6 Oct 2023 10:08:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231597AbjJFKI6 (ORCPT ); Fri, 6 Oct 2023 06:08:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231713AbjJFKI4 (ORCPT ); Fri, 6 Oct 2023 06:08:56 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C172FD6 for ; Fri, 6 Oct 2023 03:08:54 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8ADD8C433C8; Fri, 6 Oct 2023 10:08:53 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil , Hans de Goede Subject: [PATCH 1/9] staging: media: atomisp: drop check for reentrant .s_stream() Date: Fri, 6 Oct 2023 12:08:42 +0200 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The subdev .s_stream() operation shall not be called to start streaming on an already started subdev, or stop streaming on a stopped subdev. Remove the check that guards against that condition. Also fixes a smatch warning: drivers/staging/media/atomisp/i2c/atomisp-gc0310.c:446 gc0310_s_stream() warn: missing error code 'ret' Signed-off-by: Hans Verkuil CC: Hans de Goede Reviewed-by: Hans de Goede --- drivers/staging/media/atomisp/i2c/atomisp-gc0310.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/media/atomisp/i2c/atomisp-gc0310.c b/drivers/staging/media/atomisp/i2c/atomisp-gc0310.c index c438accb0472..58cddf11c9ab 100644 --- a/drivers/staging/media/atomisp/i2c/atomisp-gc0310.c +++ b/drivers/staging/media/atomisp/i2c/atomisp-gc0310.c @@ -441,11 +441,6 @@ static int gc0310_s_stream(struct v4l2_subdev *sd, int enable) dev_dbg(&client->dev, "%s S enable=%d\n", __func__, enable); mutex_lock(&dev->input_lock); - if (dev->is_streaming == enable) { - dev_warn(&client->dev, "stream already %s\n", enable ? "started" : "stopped"); - goto error_unlock; - } - if (enable) { ret = pm_runtime_get_sync(&client->dev); if (ret < 0) @@ -497,7 +492,6 @@ static int gc0310_s_stream(struct v4l2_subdev *sd, int enable) error_power_down: pm_runtime_put(&client->dev); dev->is_streaming = false; -error_unlock: mutex_unlock(&dev->input_lock); return ret; } From patchwork Fri Oct 6 10:08:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13411243 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A007E92FFF for ; Fri, 6 Oct 2023 10:09:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231691AbjJFKI7 (ORCPT ); Fri, 6 Oct 2023 06:08:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231743AbjJFKI5 (ORCPT ); Fri, 6 Oct 2023 06:08:57 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EAF3ED for ; Fri, 6 Oct 2023 03:08:56 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0AC5C433CA; Fri, 6 Oct 2023 10:08:54 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil , Sakari Ailus Subject: [PATCH 2/9] media: i2c: adp1653: don't reuse the same node pointer Date: Fri, 6 Oct 2023 12:08:43 +0200 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The child device_node pointer was used for two different childs. This confused smatch, causing this warning: drivers/media/i2c/adp1653.c:444 adp1653_of_init() warn: missing unwind goto? Use two different pointers, one for each child node, and add separate goto labels for each node as well. This also improves error logging since it will now state for which node the property was missing. Signed-off-by: Hans Verkuil CC: Sakari Ailus Acked-by: Sakari Ailus --- drivers/media/i2c/adp1653.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c index 98ca417b8004..5ace7b5804d4 100644 --- a/drivers/media/i2c/adp1653.c +++ b/drivers/media/i2c/adp1653.c @@ -411,43 +411,44 @@ static int adp1653_of_init(struct i2c_client *client, struct device_node *node) { struct adp1653_platform_data *pd; - struct device_node *child; + struct device_node *node_indicator = NULL; + struct device_node *node_flash; pd = devm_kzalloc(&client->dev, sizeof(*pd), GFP_KERNEL); if (!pd) return -ENOMEM; flash->platform_data = pd; - child = of_get_child_by_name(node, "flash"); - if (!child) + node_flash = of_get_child_by_name(node, "flash"); + if (!node_flash) return -EINVAL; - if (of_property_read_u32(child, "flash-timeout-us", + if (of_property_read_u32(node_flash, "flash-timeout-us", &pd->max_flash_timeout)) goto err; - if (of_property_read_u32(child, "flash-max-microamp", + if (of_property_read_u32(node_flash, "flash-max-microamp", &pd->max_flash_intensity)) goto err; pd->max_flash_intensity /= 1000; - if (of_property_read_u32(child, "led-max-microamp", + if (of_property_read_u32(node_flash, "led-max-microamp", &pd->max_torch_intensity)) goto err; pd->max_torch_intensity /= 1000; - of_node_put(child); - child = of_get_child_by_name(node, "indicator"); - if (!child) - return -EINVAL; + node_indicator = of_get_child_by_name(node, "indicator"); + if (!node_indicator) + goto err; - if (of_property_read_u32(child, "led-max-microamp", + if (of_property_read_u32(node_indicator, "led-max-microamp", &pd->max_indicator_intensity)) goto err; - of_node_put(child); + of_node_put(node_flash); + of_node_put(node_indicator); pd->enable_gpio = devm_gpiod_get(&client->dev, "enable", GPIOD_OUT_LOW); if (IS_ERR(pd->enable_gpio)) { @@ -458,7 +459,8 @@ static int adp1653_of_init(struct i2c_client *client, return 0; err: dev_err(&client->dev, "Required property not found\n"); - of_node_put(child); + of_node_put(node_flash); + of_node_put(node_indicator); return -EINVAL; } From patchwork Fri Oct 6 10:08:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13411242 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2685E92711 for ; Fri, 6 Oct 2023 10:09:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231695AbjJFKJA (ORCPT ); Fri, 6 Oct 2023 06:09:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231559AbjJFKI6 (ORCPT ); Fri, 6 Oct 2023 06:08:58 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC782EB for ; Fri, 6 Oct 2023 03:08:57 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 226E4C433CB; Fri, 6 Oct 2023 10:08:55 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil , Hans de Goede Subject: [PATCH 3/9] staging: media: atomisp: improve unwinding Date: Fri, 6 Oct 2023 12:08:44 +0200 Message-Id: <97bf2e6dcba166ba77a9c35e3fe7b0f20a0abf7a.1696586632.git.hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This fixes two smatch warnings: drivers/staging/media/atomisp/pci/atomisp_cmd.c:2779 atomisp_cp_dvs_6axis_config() warn: missing unwind goto? drivers/staging/media/atomisp/pci/atomisp_cmd.c:2878 atomisp_cp_morph_table() warn: missing unwind goto? Signed-off-by: Hans Verkuil CC: Hans de Goede Reviewed-by: Hans de Goede --- .../staging/media/atomisp/pci/atomisp_cmd.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp_cmd.c index a54be2d20c58..759233a7ba50 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c +++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c @@ -2771,12 +2771,16 @@ int atomisp_cp_dvs_6axis_config(struct atomisp_sub_device *asd, css_param->dvs_6axis = NULL; dvs_6axis_config = ia_css_dvs2_6axis_config_allocate(stream); - if (!dvs_6axis_config) - return -ENOMEM; + if (!dvs_6axis_config) { + ret = -ENOMEM; + goto error; + } } else if (!dvs_6axis_config) { dvs_6axis_config = ia_css_dvs2_6axis_config_allocate(stream); - if (!dvs_6axis_config) - return -ENOMEM; + if (!dvs_6axis_config) { + ret = -ENOMEM; + goto error; + } } dvs_6axis_config->exp_id = source_6axis_config->exp_id; @@ -2874,8 +2878,10 @@ int atomisp_cp_morph_table(struct atomisp_sub_device *asd, morph_table = atomisp_css_morph_table_allocate( source_morph_table->width, source_morph_table->height); - if (!morph_table) - return -ENOMEM; + if (!morph_table) { + ret = -ENOMEM; + goto error; + } for (i = 0; i < IA_CSS_MORPH_TABLE_NUM_PLANES; i++) { if (copy_from_compatible(morph_table->coordinates_x[i], From patchwork Fri Oct 6 10:08:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13411244 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 474AFE92FFB for ; Fri, 6 Oct 2023 10:09:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231680AbjJFKJA (ORCPT ); Fri, 6 Oct 2023 06:09:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231594AbjJFKJA (ORCPT ); Fri, 6 Oct 2023 06:09:00 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB5CB9F for ; Fri, 6 Oct 2023 03:08:58 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 684B1C433C8; Fri, 6 Oct 2023 10:08:57 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil , Mauro Carvalho Chehab Subject: [PATCH 4/9] media: dvb-usb-v2: af9035: fix missing unlock Date: Fri, 6 Oct 2023 12:08:45 +0200 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Instead of returning an error, goto the mutex unlock at the end of the function. Fixes smatch warning: drivers/media/usb/dvb-usb-v2/af9035.c:467 af9035_i2c_master_xfer() warn: inconsistent returns '&d->i2c_mutex'. Locked on : 326,387 Unlocked on: 465,467 Signed-off-by: Hans Verkuil CC: Mauro Carvalho Chehab --- drivers/media/usb/dvb-usb-v2/af9035.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c index 33a2aa8907e6..4eb7dd4599b7 100644 --- a/drivers/media/usb/dvb-usb-v2/af9035.c +++ b/drivers/media/usb/dvb-usb-v2/af9035.c @@ -322,8 +322,10 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap, ret = -EOPNOTSUPP; } else if ((msg[0].addr == state->af9033_i2c_addr[0]) || (msg[0].addr == state->af9033_i2c_addr[1])) { - if (msg[0].len < 3 || msg[1].len < 1) - return -EOPNOTSUPP; + if (msg[0].len < 3 || msg[1].len < 1) { + ret = -EOPNOTSUPP; + goto unlock; + } /* demod access via firmware interface */ u32 reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 | msg[0].buf[2]; @@ -383,8 +385,10 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap, ret = -EOPNOTSUPP; } else if ((msg[0].addr == state->af9033_i2c_addr[0]) || (msg[0].addr == state->af9033_i2c_addr[1])) { - if (msg[0].len < 3) - return -EOPNOTSUPP; + if (msg[0].len < 3) { + ret = -EOPNOTSUPP; + goto unlock; + } /* demod access via firmware interface */ u32 reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 | msg[0].buf[2]; @@ -459,6 +463,7 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap, ret = -EOPNOTSUPP; } +unlock: mutex_unlock(&d->i2c_mutex); if (ret < 0) From patchwork Fri Oct 6 10:08:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13411245 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33BA8E92712 for ; Fri, 6 Oct 2023 10:09:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231693AbjJFKJC (ORCPT ); Fri, 6 Oct 2023 06:09:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231664AbjJFKJA (ORCPT ); Fri, 6 Oct 2023 06:09:00 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6F80FD for ; Fri, 6 Oct 2023 03:08:59 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9A36C433CC; Fri, 6 Oct 2023 10:08:58 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil , Mirela Rabulea , NXP Linux Team Subject: [PATCH 5/9] media: nxp: imx-jpeg: use goto instead of return Date: Fri, 6 Oct 2023 12:08:46 +0200 Message-Id: <64c3edcac5e3193303e87d3be04bfa12ebf43e71.1696586632.git.hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org For consistency use goto instead of return. This fixes a smatch warning: drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c:2792 mxc_jpeg_probe() warn: missing unwind goto? Signed-off-by: Hans Verkuil CC: Mirela Rabulea CC: NXP Linux Team --- drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c index e74b0ed8ec5b..1fc6b3660bdd 100644 --- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c @@ -2789,7 +2789,7 @@ static int mxc_jpeg_probe(struct platform_device *pdev) ret = mxc_jpeg_attach_pm_domains(jpeg); if (ret < 0) { dev_err(dev, "failed to attach power domains %d\n", ret); - return ret; + goto err_clk; } /* v4l2 */ From patchwork Fri Oct 6 10:08:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13411246 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC965E92FFB for ; Fri, 6 Oct 2023 10:09:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231698AbjJFKJG (ORCPT ); Fri, 6 Oct 2023 06:09:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231629AbjJFKJE (ORCPT ); Fri, 6 Oct 2023 06:09:04 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E9A9100 for ; Fri, 6 Oct 2023 03:09:02 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B1E9C433C9; Fri, 6 Oct 2023 10:09:00 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil , Stanimir Varbanov , Vikash Garodia , "Bryan O'Donoghue" Subject: [PATCH 6/9] media: qcom: venus: fix incorrect return value Date: Fri, 6 Oct 2023 12:08:47 +0200 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 'pd' can be NULL, and in that case it shouldn't be passed to PTR_ERR. Fixes a smatch warning: drivers/media/platform/qcom/venus/pm_helpers.c:873 vcodec_domains_get() warn: passing zero to 'PTR_ERR' Signed-off-by: Hans Verkuil CC: Stanimir Varbanov CC: Vikash Garodia CC: "Bryan O'Donoghue" Reviewed-by: Bryan O'Donoghue --- drivers/media/platform/qcom/venus/pm_helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/qcom/venus/pm_helpers.c b/drivers/media/platform/qcom/venus/pm_helpers.c index 48c9084bb4db..a1b127caa90a 100644 --- a/drivers/media/platform/qcom/venus/pm_helpers.c +++ b/drivers/media/platform/qcom/venus/pm_helpers.c @@ -870,7 +870,7 @@ static int vcodec_domains_get(struct venus_core *core) pd = dev_pm_domain_attach_by_name(dev, res->vcodec_pmdomains[i]); if (IS_ERR_OR_NULL(pd)) - return PTR_ERR(pd) ? : -ENODATA; + return pd ? PTR_ERR(pd) : -ENODATA; core->pmdomains[i] = pd; } From patchwork Fri Oct 6 10:08:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13411247 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B1A0E92FDE for ; Fri, 6 Oct 2023 10:09:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231664AbjJFKJH (ORCPT ); Fri, 6 Oct 2023 06:09:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231655AbjJFKJE (ORCPT ); Fri, 6 Oct 2023 06:09:04 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 321EAF0 for ; Fri, 6 Oct 2023 03:09:03 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA25DC433CA; Fri, 6 Oct 2023 10:09:01 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil , Sakari Ailus Subject: [PATCH 7/9] media: i2c: tc358746: check fmt validity Date: Fri, 6 Oct 2023 12:08:48 +0200 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Check if the format was really found. Fixes smatch warning: drivers/media/i2c/tc358746.c:790 tc358746_set_fmt() error: 'fmt' dereferencing possible ERR_PTR() Signed-off-by: Hans Verkuil CC: Sakari Ailus Reviewed-by: Sakari Ailus --- drivers/media/i2c/tc358746.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/tc358746.c b/drivers/media/i2c/tc358746.c index 566f5eaddd57..ce612a47ba84 100644 --- a/drivers/media/i2c/tc358746.c +++ b/drivers/media/i2c/tc358746.c @@ -784,8 +784,12 @@ static int tc358746_set_fmt(struct v4l2_subdev *sd, sink_fmt = v4l2_subdev_get_pad_format(sd, sd_state, TC358746_SINK); fmt = tc358746_get_format_by_code(format->pad, format->format.code); - if (IS_ERR(fmt)) + if (IS_ERR(fmt)) { fmt = tc358746_get_format_by_code(format->pad, tc358746_def_fmt.code); + // Can't happen, but just in case... + if (WARN_ON(IS_ERR(fmt))) + return -EINVAL; + } format->format.code = fmt->code; format->format.field = V4L2_FIELD_NONE; From patchwork Fri Oct 6 10:08:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13411248 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9AB9BE92FFF for ; Fri, 6 Oct 2023 10:09:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231705AbjJFKJI (ORCPT ); Fri, 6 Oct 2023 06:09:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231663AbjJFKJF (ORCPT ); Fri, 6 Oct 2023 06:09:05 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8865CFD for ; Fri, 6 Oct 2023 03:09:04 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2BD5BC433D9; Fri, 6 Oct 2023 10:09:02 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil , Laurent Pinchart Subject: [PATCH 8/9] media: i2c: mt9m114: goto proper error path Date: Fri, 6 Oct 2023 12:08:49 +0200 Message-Id: <6e2b3d5971905c1cf63184e7c3cd269c10151bb7.1696586632.git.hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org In two places the probe function returns instead of going to the correct goto label. This fixes this smatch warning: drivers/media/i2c/mt9m114.c:2381 mt9m114_probe() warn: missing unwind goto? Signed-off-by: Hans Verkuil CC: Laurent Pinchart --- drivers/media/i2c/mt9m114.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/mt9m114.c b/drivers/media/i2c/mt9m114.c index dae675e52390..ac19078ceda3 100644 --- a/drivers/media/i2c/mt9m114.c +++ b/drivers/media/i2c/mt9m114.c @@ -2367,7 +2367,7 @@ static int mt9m114_probe(struct i2c_client *client) ret = mt9m114_clk_init(sensor); if (ret) - return ret; + goto error_ep_free; /* * Identify the sensor. The driver supports runtime PM, but needs to @@ -2378,7 +2378,7 @@ static int mt9m114_probe(struct i2c_client *client) ret = mt9m114_power_on(sensor); if (ret < 0) { dev_err_probe(dev, ret, "Could not power on the device\n"); - return ret; + goto error_ep_free; } ret = mt9m114_identify(sensor); From patchwork Fri Oct 6 10:08:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13411249 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BCB5E92711 for ; Fri, 6 Oct 2023 10:09:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231666AbjJFKJJ (ORCPT ); Fri, 6 Oct 2023 06:09:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231657AbjJFKJH (ORCPT ); Fri, 6 Oct 2023 06:09:07 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD80DF0 for ; Fri, 6 Oct 2023 03:09:05 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 732D0C433AD; Fri, 6 Oct 2023 10:09:04 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil , Martin Tuma Subject: [PATCH 9/9] media: pci: mgb4: fix potential spectre vulnerability Date: Fri, 6 Oct 2023 12:08:50 +0200 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Fix smatch warnings: drivers/media/pci/mgb4/mgb4_sysfs_out.c:118 video_source_store() warn: potential spectre issue 'mgbdev->vin' [r] (local cap) drivers/media/pci/mgb4/mgb4_sysfs_out.c:122 video_source_store() warn: possible spectre second half. 'loopin_new' Signed-off-by: Hans Verkuil CC: Martin Tuma Reviewed-by: Martin Tůma --- drivers/media/pci/mgb4/mgb4_sysfs_out.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/media/pci/mgb4/mgb4_sysfs_out.c b/drivers/media/pci/mgb4/mgb4_sysfs_out.c index 23a9aabf3915..9f6e81c57726 100644 --- a/drivers/media/pci/mgb4/mgb4_sysfs_out.c +++ b/drivers/media/pci/mgb4/mgb4_sysfs_out.c @@ -8,6 +8,7 @@ */ #include +#include #include "mgb4_core.h" #include "mgb4_i2c.h" #include "mgb4_vout.h" @@ -114,8 +115,10 @@ static ssize_t video_source_store(struct device *dev, if (((config & 0xc) >> 2) < MGB4_VIN_DEVICES) loopin_old = mgbdev->vin[(config & 0xc) >> 2]; - if (val < MGB4_VIN_DEVICES) + if (val < MGB4_VIN_DEVICES) { + val = array_index_nospec(val, MGB4_VIN_DEVICES); loopin_new = mgbdev->vin[val]; + } if (loopin_old && loopin_cnt(loopin_old) == 1) mgb4_mask_reg(&mgbdev->video, loopin_old->config->regs.config, 0x2, 0x0);