From patchwork Mon Mar 25 22:03:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 10870153 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6AED318A6 for ; Mon, 25 Mar 2019 22:03:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57027290B8 for ; Mon, 25 Mar 2019 22:03:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48632290E9; Mon, 25 Mar 2019 22:03:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7C02290BC for ; Mon, 25 Mar 2019 22:03:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730615AbfCYWDm (ORCPT ); Mon, 25 Mar 2019 18:03:42 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:54888 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730187AbfCYWDm (ORCPT ); Mon, 25 Mar 2019 18:03:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=/deS02s9ycDGmZNU04NggU6EJ76B3Vk4QaC1citBKvg=; b=sbmW4BvrsHn1UGdQngHJ6L9l2a 9wgl8SI22Ui0WA6KlCIyrhXXXkPrjBId3rmaZvkpIHPBCvCj5fbShz+CWBr0ls1TGPNHeFK/y7ais B9fRcCH+bOFEVV5ekcPFxb6xOtY/iAJtw0Vm/nkkinVRaBg2llmRrmHDOWkAFSy0ajq5IiyHbHPZ5 5ZdrPeNYU0w8a+uCIUXcsLHxE6iL7v0kLrN77q6jvLYaccSoEyP8i+KnwbZqj+MMvojfwcfFqYO6V 4Hl+BmfwLlxiYl4+PmiprkpzHv31rJ2rpZwYk6XiGEc3O5u+eaygmOOIAg4/ig1WfDsr3HxVlTzg0 +nEEbwjA==; Received: from 177.41.113.24.dynamic.adsl.gvt.net.br ([177.41.113.24] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1h8Xgz-0001YE-NX; Mon, 25 Mar 2019 22:03:41 +0000 Received: from mchehab by bombadil.infradead.org with local (Exim 4.92) (envelope-from ) id 1h8Xgw-0001ah-Gr; Mon, 25 Mar 2019 18:03:38 -0400 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Mauro Carvalho Chehab , Hans Verkuil Subject: [PATCH 1/5] media: cx2341x: replace badly designed macros Date: Mon, 25 Mar 2019 18:03:33 -0400 Message-Id: <3d19cde7be76d4471426edc348bcf3b45c64f097.1553551369.git.mchehab+samsung@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There are some macros at cx2341x_update() with seemed to be introduced in order to ensure that lines would be less than 80 columns. Well, the thing is that they make the code harder to be analized, not only by humans, but also for static code analyzers: drivers/media/common/cx2341x.c:1116 cx2341x_update() error: we previously assumed 'old' could be null (see line 1047) So, remove the "force" var, and replace the NEQ macro to a better designed one that makes clearer about what it is doing. While here, also remove the "temporal" var, as it is just another way of doing the same type of check as the new CMP_FIELD() macro already does. Finally, fix coding style at the block code. remove such macros. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/common/cx2341x.c | 151 ++++++++++++++++++++------------- 1 file changed, 93 insertions(+), 58 deletions(-) diff --git a/drivers/media/common/cx2341x.c b/drivers/media/common/cx2341x.c index 1dcc39b87bb7..121cda73ff88 100644 --- a/drivers/media/common/cx2341x.c +++ b/drivers/media/common/cx2341x.c @@ -1028,7 +1028,7 @@ static int cx2341x_api(void *priv, cx2341x_mbox_func func, return func(priv, cmd, args, 0, data); } -#define NEQ(field) (old->field != new->field) +#define CMP_FIELD(__old, __new, __field) (__old->__field != __new->__field) int cx2341x_update(void *priv, cx2341x_mbox_func func, const struct cx2341x_mpeg_params *old, @@ -1042,20 +1042,22 @@ int cx2341x_update(void *priv, cx2341x_mbox_func func, 11, /* VCD */ 12, /* SVCD */ }; - - int err = 0; - int force = (old == NULL); - u16 temporal = new->video_temporal_filter; + int err; cx2341x_api(priv, func, CX2341X_ENC_SET_OUTPUT_PORT, 2, new->port, 0); - if (force || NEQ(is_50hz)) { + if (!old || + CMP_FIELD(old, new, is_50hz)) { err = cx2341x_api(priv, func, CX2341X_ENC_SET_FRAME_RATE, 1, new->is_50hz); - if (err) return err; + if (err) + return err; } - if (force || NEQ(width) || NEQ(height) || NEQ(video_encoding)) { + if (!old || + CMP_FIELD(old, new, width) || + CMP_FIELD(old, new, height) || + CMP_FIELD(old, new, video_encoding)) { u16 w = new->width; u16 h = new->height; @@ -1065,94 +1067,127 @@ int cx2341x_update(void *priv, cx2341x_mbox_func func, } err = cx2341x_api(priv, func, CX2341X_ENC_SET_FRAME_SIZE, 2, h, w); - if (err) return err; + if (err) + return err; } - if (force || NEQ(stream_type)) { + if (!old || + CMP_FIELD(old, new, stream_type)) { err = cx2341x_api(priv, func, CX2341X_ENC_SET_STREAM_TYPE, 1, mpeg_stream_type[new->stream_type]); - if (err) return err; + if (err) + return err; } - if (force || NEQ(video_aspect)) { + if (!old || + CMP_FIELD(old, new, video_aspect)) { err = cx2341x_api(priv, func, CX2341X_ENC_SET_ASPECT_RATIO, 1, 1 + new->video_aspect); - if (err) return err; + if (err) + return err; } - if (force || NEQ(video_b_frames) || NEQ(video_gop_size)) { + if (!old || + CMP_FIELD(old, new, video_b_frames) || + CMP_FIELD(old, new, video_gop_size)) { err = cx2341x_api(priv, func, CX2341X_ENC_SET_GOP_PROPERTIES, 2, - new->video_gop_size, new->video_b_frames + 1); - if (err) return err; + new->video_gop_size, new->video_b_frames + 1); + if (err) + return err; } - if (force || NEQ(video_gop_closure)) { + if (!old || + CMP_FIELD(old, new, video_gop_closure)) { err = cx2341x_api(priv, func, CX2341X_ENC_SET_GOP_CLOSURE, 1, new->video_gop_closure); - if (err) return err; + if (err) + return err; } - if (force || NEQ(audio_properties)) { + if (!old || + CMP_FIELD(old, new, audio_properties)) { err = cx2341x_api(priv, func, CX2341X_ENC_SET_AUDIO_PROPERTIES, 1, new->audio_properties); - if (err) return err; + if (err) + return err; } - if (force || NEQ(audio_mute)) { + if (!old || + CMP_FIELD(old, new, audio_mute)) { err = cx2341x_api(priv, func, CX2341X_ENC_MUTE_AUDIO, 1, new->audio_mute); - if (err) return err; + if (err) + return err; } - if (force || NEQ(video_bitrate_mode) || NEQ(video_bitrate) || - NEQ(video_bitrate_peak)) { + if (!old || + CMP_FIELD(old, new, video_bitrate_mode) || + CMP_FIELD(old, new, video_bitrate) || + CMP_FIELD(old, new, video_bitrate_peak)) { err = cx2341x_api(priv, func, CX2341X_ENC_SET_BIT_RATE, 5, - new->video_bitrate_mode, new->video_bitrate, - new->video_bitrate_peak / 400, 0, 0); - if (err) return err; + new->video_bitrate_mode, new->video_bitrate, + new->video_bitrate_peak / 400, 0, 0); + if (err) + return err; } - if (force || NEQ(video_spatial_filter_mode) || - NEQ(video_temporal_filter_mode) || - NEQ(video_median_filter_type)) { + if (!old || + CMP_FIELD(old, new, video_spatial_filter_mode) || + CMP_FIELD(old, new, video_temporal_filter_mode) || + CMP_FIELD(old, new, video_median_filter_type)) { err = cx2341x_api(priv, func, CX2341X_ENC_SET_DNR_FILTER_MODE, - 2, new->video_spatial_filter_mode | + 2, + new->video_spatial_filter_mode | (new->video_temporal_filter_mode << 1), - new->video_median_filter_type); - if (err) return err; + new->video_median_filter_type); + if (err) + return err; } - if (force || NEQ(video_luma_median_filter_bottom) || - NEQ(video_luma_median_filter_top) || - NEQ(video_chroma_median_filter_bottom) || - NEQ(video_chroma_median_filter_top)) { + if (!old || + CMP_FIELD(old, new, video_luma_median_filter_bottom) || + CMP_FIELD(old, new, video_luma_median_filter_top) || + CMP_FIELD(old, new, video_chroma_median_filter_bottom) || + CMP_FIELD(old, new, video_chroma_median_filter_top)) { err = cx2341x_api(priv, func, CX2341X_ENC_SET_CORING_LEVELS, 4, - new->video_luma_median_filter_bottom, - new->video_luma_median_filter_top, - new->video_chroma_median_filter_bottom, - new->video_chroma_median_filter_top); - if (err) return err; + new->video_luma_median_filter_bottom, + new->video_luma_median_filter_top, + new->video_chroma_median_filter_bottom, + new->video_chroma_median_filter_top); + if (err) + return err; } - if (force || NEQ(video_luma_spatial_filter_type) || - NEQ(video_chroma_spatial_filter_type)) { + if (!old || + CMP_FIELD(old, new, video_luma_spatial_filter_type) || + CMP_FIELD(old, new, video_chroma_spatial_filter_type)) { err = cx2341x_api(priv, func, CX2341X_ENC_SET_SPATIAL_FILTER_TYPE, 2, new->video_luma_spatial_filter_type, new->video_chroma_spatial_filter_type); - if (err) return err; + if (err) + return err; } - if (force || NEQ(video_spatial_filter) || - old->video_temporal_filter != temporal) { + if (!old || + CMP_FIELD(old, new, video_spatial_filter) || + CMP_FIELD(old, new, video_temporal_filter)) { err = cx2341x_api(priv, func, CX2341X_ENC_SET_DNR_FILTER_PROPS, - 2, new->video_spatial_filter, temporal); - if (err) return err; + 2, new->video_spatial_filter, + new->video_temporal_filter); + if (err) + return err; } - if (force || NEQ(video_temporal_decimation)) { + if (!old || + CMP_FIELD(old, new, video_temporal_decimation)) { err = cx2341x_api(priv, func, CX2341X_ENC_SET_FRAME_DROP_RATE, 1, new->video_temporal_decimation); - if (err) return err; + if (err) + return err; } - if (force || NEQ(video_mute) || - (new->video_mute && NEQ(video_mute_yuv))) { + if (!old || + CMP_FIELD(old, new, video_mute) || + (new->video_mute && CMP_FIELD(old, new, video_mute_yuv))) { err = cx2341x_api(priv, func, CX2341X_ENC_MUTE_VIDEO, 1, - new->video_mute | (new->video_mute_yuv << 8)); - if (err) return err; + new->video_mute | (new->video_mute_yuv << 8)); + if (err) + return err; } - if (force || NEQ(stream_insert_nav_packets)) { + if (!old || + CMP_FIELD(old, new, stream_insert_nav_packets)) { err = cx2341x_api(priv, func, CX2341X_ENC_MISC, 2, - 7, new->stream_insert_nav_packets); - if (err) return err; + 7, new->stream_insert_nav_packets); + if (err) + return err; } return 0; } From patchwork Mon Mar 25 22:03:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 10870157 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B7162922 for ; Mon, 25 Mar 2019 22:03:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3251290BC for ; Mon, 25 Mar 2019 22:03:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9745C290E9; Mon, 25 Mar 2019 22:03:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 396B5290B8 for ; Mon, 25 Mar 2019 22:03:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730616AbfCYWDo (ORCPT ); Mon, 25 Mar 2019 18:03:44 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:54914 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730006AbfCYWDm (ORCPT ); Mon, 25 Mar 2019 18:03:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=JMuLDl4OtgdYsBvKKL7DpQ6Euc4wIOaih+OS0AYRBto=; b=SB3YPrzVGnrNVTIe84RRkTwENh eZHhemB7AGSaNRL6v1jijNWfSQmnMisi1o8Tp/X68rfogNUyJt7N9+hOD/qMD2VBTnCdJ2AXpS5gL f6YKMz7vmJgmZMi0gXbWNKI8aSTwQ1XzTAvI+Z5i+akPccM0LxBHskjoGgSExuSQVr5THzODB2L5f ogH3zxGdCrmQGWO4aUYTn6tH+OBWrfbU1aGsEBg4OQdFKKPZv7EAPwQu2LL5dG49udPPvHnae7Ca3 cxJMg5l+xTpMVWj2cbn19IYMuKQkZKhO8/WmhqMqv6vaWxjdA1KAhQokbcIh1xyakNoJf/UtOFUMB mJXjC0IA==; Received: from 177.41.113.24.dynamic.adsl.gvt.net.br ([177.41.113.24] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1h8Xh0-0001YD-E0; Mon, 25 Mar 2019 22:03:42 +0000 Received: from mchehab by bombadil.infradead.org with local (Exim 4.92) (envelope-from ) id 1h8Xgw-0001al-Hq; Mon, 25 Mar 2019 18:03:38 -0400 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Mauro Carvalho Chehab , Hans Verkuil Subject: [PATCH 2/5] media: pwc-ctl: pChoose can't be NULL Date: Mon, 25 Mar 2019 18:03:34 -0400 Message-Id: <4f777d011bdd9e78fcf02701e89c8be457504a6c.1553551369.git.mchehab+samsung@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The way the code works, compression will be a valid value (less or equal to 3) on both set_video_mode_foo() calls at the beginning of the while() loop. So, the value for pChoose can't be NULL. Solves those smatch warnings: drivers/media/usb/pwc/pwc-ctrl.c: drivers/media/usb/pwc/pwc-ctrl.c:252 set_video_mode_Timon() warn: variable dereferenced before check 'pChoose' (see line 248) drivers/media/usb/pwc/pwc-ctrl.c: drivers/media/usb/pwc/pwc-ctrl.c:302 set_video_mode_Kiara() warn: variable dereferenced before check 'pChoose' (see line 298) and simplifies the code a little bit. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/pwc/pwc-ctrl.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/media/usb/pwc/pwc-ctrl.c b/drivers/media/usb/pwc/pwc-ctrl.c index 655cef39eb3d..b681a184ef87 100644 --- a/drivers/media/usb/pwc/pwc-ctrl.c +++ b/drivers/media/usb/pwc/pwc-ctrl.c @@ -242,14 +242,14 @@ static int set_video_mode_Timon(struct pwc_device *pdev, int size, int pixfmt, fps = (frames / 5) - 1; /* Find a supported framerate with progressively higher compression */ - pChoose = NULL; - while (*compression <= 3) { + do { pChoose = &Timon_table[size][fps][*compression]; if (pChoose->alternate != 0) break; (*compression)++; - } - if (pChoose == NULL || pChoose->alternate == 0) + } while (*compression <= 3); + + if (pChoose->alternate == 0) return -ENOENT; /* Not supported. */ if (send_to_cam) @@ -279,7 +279,7 @@ static int set_video_mode_Timon(struct pwc_device *pdev, int size, int pixfmt, static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int pixfmt, int frames, int *compression, int send_to_cam) { - const struct Kiara_table_entry *pChoose = NULL; + const struct Kiara_table_entry *pChoose; int fps, ret = 0; if (size >= PSZ_MAX || *compression < 0 || *compression > 3) @@ -293,13 +293,14 @@ static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int pixfmt, fps = (frames / 5) - 1; /* Find a supported framerate with progressively higher compression */ - while (*compression <= 3) { + do { pChoose = &Kiara_table[size][fps][*compression]; if (pChoose->alternate != 0) break; (*compression)++; - } - if (pChoose == NULL || pChoose->alternate == 0) + } while (*compression <= 3); + + if (pChoose->alternate == 0) return -ENOENT; /* Not supported. */ /* Firmware bug: video endpoint is 5, but commands are sent to endpoint 4 */ From patchwork Mon Mar 25 22:03:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 10870165 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 82D9A922 for ; Mon, 25 Mar 2019 22:03:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70128290BC for ; Mon, 25 Mar 2019 22:03:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 648E0290EB; Mon, 25 Mar 2019 22:03:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1EF5C290BC for ; Mon, 25 Mar 2019 22:03:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730285AbfCYWDq (ORCPT ); Mon, 25 Mar 2019 18:03:46 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:54910 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730599AbfCYWDm (ORCPT ); Mon, 25 Mar 2019 18:03:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=xjmBaASz+r+k0qOF+7TrxhfSvYpuLnSdwYZX2rjbPbY=; b=FGASW+R102EXsHavOWER5MfrO/ J81T45j4FVuQSmnf90k5ZxjWM7wUvClPKdzEuXhFMG7OeCfct5O8G2A21SgkixaP6vxcVtIxG97Wc mWYbXwVgvNJPC0wC8/sUZGKt3pRXllNgPHz2vp+kbGl3DXtXlfas4/2HZjSIisTlLljUlxIzAxBWF 9TDIAEYVO9BGuRG6KoDq7y5+CaED8XcRk8TIJbC4DTIAp7CDcwWkUDMAVtxWRGrVRVLlObUx2JIxL X3y598h8pOMBFw9C0vf58V2AoH/BuvUpfqyhMFuP+q+7Ls2WyIbZvPQ3iPMWNO5gvXDKpsR/+hUT9 YpWWfF9Q==; Received: from 177.41.113.24.dynamic.adsl.gvt.net.br ([177.41.113.24] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1h8Xh0-0001YG-Cl; Mon, 25 Mar 2019 22:03:42 +0000 Received: from mchehab by bombadil.infradead.org with local (Exim 4.92) (envelope-from ) id 1h8Xgw-0001ap-Ip; Mon, 25 Mar 2019 18:03:38 -0400 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Mauro Carvalho Chehab , Hugues Fruchet Subject: [PATCH 3/5] media: sti/delta: remove uneeded check Date: Mon, 25 Mar 2019 18:03:35 -0400 Message-Id: <1021cd56772b636ebccc3941c44094ef6b0fac4e.1553551369.git.mchehab+samsung@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP At the error logic, ipc_buf was already asigned to &ctx->ipc_buf_struct, with can't be null, as warned by smatch: drivers/media/platform/sti/delta/delta-ipc.c:223 delta_ipc_open() warn: variable dereferenced before check 'ctx->ipc_buf' (see line 183) So, remove the uneeded check. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/sti/delta/delta-ipc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/sti/delta/delta-ipc.c b/drivers/media/platform/sti/delta/delta-ipc.c index a4603d573c34..186d88f02ecd 100644 --- a/drivers/media/platform/sti/delta/delta-ipc.c +++ b/drivers/media/platform/sti/delta/delta-ipc.c @@ -220,10 +220,8 @@ int delta_ipc_open(struct delta_ctx *pctx, const char *name, err: pctx->sys_errors++; - if (ctx->ipc_buf) { - hw_free(pctx, ctx->ipc_buf); - ctx->ipc_buf = NULL; - } + hw_free(pctx, ctx->ipc_buf); + ctx->ipc_buf = NULL; return ret; }; From patchwork Mon Mar 25 22:03:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 10870151 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C257C922 for ; Mon, 25 Mar 2019 22:03:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B23CD290B8 for ; Mon, 25 Mar 2019 22:03:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A183329140; Mon, 25 Mar 2019 22:03:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BA6E290E9 for ; Mon, 25 Mar 2019 22:03:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730601AbfCYWDm (ORCPT ); Mon, 25 Mar 2019 18:03:42 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:54880 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730006AbfCYWDm (ORCPT ); Mon, 25 Mar 2019 18:03:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=D37LR49oRn1OGbJ/FtuBRk8QnqmadVtvTMVLlC3goZo=; b=lg6u7bv5HtnwBfL1bP6wuyPNJa sPLrPIJXq0MbDg/LGKGGdSlXrBURXrl3V+nNyAIQ/5PwW0/Rmbb87AqlwuBOAaxnnBR/TPukqHhfn Uk4j4uTYlwPiBzVS2oDvwZOOMM2IvvqMgcDNK/+sPdmwZTOl8H0MojObHOwzLwc4S+W8G1Ccm/ynB 59uUKPeu2yj3BExDET03w6lo+MRAWZZ0g3WCSjCETG7JwPWoPDF1cWwTounB/g9FDaZw3Qwj5+UYk TmiJZXIqv06JFvtHk2rA4wCjvZT8d9lXgcAZInH+qrqt22Wz6nJsHWi6Nm6p27+T6FkfIYNFBhNYZ /J5h0jsg==; Received: from 177.41.113.24.dynamic.adsl.gvt.net.br ([177.41.113.24] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1h8Xgz-0001YF-Nb; Mon, 25 Mar 2019 22:03:41 +0000 Received: from mchehab by bombadil.infradead.org with local (Exim 4.92) (envelope-from ) id 1h8Xgw-0001at-JY; Mon, 25 Mar 2019 18:03:38 -0400 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Mauro Carvalho Chehab , =?utf-8?q?Niklas_S=C3=B6derl?= =?utf-8?q?und?= , linux-renesas-soc@vger.kernel.org Subject: [PATCH 4/5] media: rcar-dma: p_set can't be NULL Date: Mon, 25 Mar 2019 18:03:36 -0400 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The only way for p_set to be NULL would be if vin_coef_set would be an empty array. On such case, the driver will OOPS, as it would try to de-reference a NULL value. So, the check if p_set is not NULL doesn't make any sense. Solves those two smatch warnings: drivers/media/platform/rcar-vin/rcar-dma.c:489 rvin_set_coeff() warn: variable dereferenced before check 'p_set' (see line 484) drivers/media/platform/rcar-vin/rcar-dma.c:494 rvin_set_coeff() error: we previously assumed 'p_set' could be null (see line 489) Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/rcar-vin/rcar-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c b/drivers/media/platform/rcar-vin/rcar-dma.c index 2207a31d355e..91ab064404a1 100644 --- a/drivers/media/platform/rcar-vin/rcar-dma.c +++ b/drivers/media/platform/rcar-vin/rcar-dma.c @@ -486,7 +486,7 @@ static void rvin_set_coeff(struct rvin_dev *vin, unsigned short xs) } /* Use previous value if its XS value is closer */ - if (p_prev_set && p_set && + if (p_prev_set && xs - p_prev_set->xs_value < p_set->xs_value - xs) p_set = p_prev_set; From patchwork Mon Mar 25 22:03:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 10870161 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E4DC21708 for ; Mon, 25 Mar 2019 22:03:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1304290B8 for ; Mon, 25 Mar 2019 22:03:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5D2A290E9; Mon, 25 Mar 2019 22:03:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73653290B8 for ; Mon, 25 Mar 2019 22:03:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730599AbfCYWDq (ORCPT ); Mon, 25 Mar 2019 18:03:46 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:54904 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730239AbfCYWDm (ORCPT ); Mon, 25 Mar 2019 18:03:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=8VVRBoSZaHcx+Icp5Vi++XQ8nBFddv1snNBVIo4konU=; b=Iz4j6C2sVemHUewI0E5Aw94XJV cQGpZtcJ9Fw+TN9qySMhsdetqPnjMbPZBZn+CGREaMH2gC0ItGvg7f3obBgan0IoAS1YYaOpTs2cQ sNijvnSRKht/NrJ0NfmFCbZ27RQlhZrrXr0iDmT9GgrySNdL949PliWkMqvvLZbygteJK1yN9/MRW ECW7ONLquSNWw8+ZTw7kClJItd3B5AxMKsVMIfksrZ/S/juVotghRgTDQ5a+no2WcYNI9Xp6sQV1m zup8hYoogEJvslVsYH9IblRZ7oWtMd1LoTb5JITXUYqW2QEWi+rVPsIBmg3RD+xpzTCKn5km8s1nQ KkRWeDDA==; Received: from 177.41.113.24.dynamic.adsl.gvt.net.br ([177.41.113.24] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1h8Xh0-0001YH-AV; Mon, 25 Mar 2019 22:03:42 +0000 Received: from mchehab by bombadil.infradead.org with local (Exim 4.92) (envelope-from ) id 1h8Xgw-0001ax-KH; Mon, 25 Mar 2019 18:03:38 -0400 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Mauro Carvalho Chehab , Stanimir Varbanov , Andy Gross , David Brown , linux-arm-msm@vger.kernel.org Subject: [PATCH 5/5] media: hfi_parser: don't trick gcc with a wrong expected size Date: Mon, 25 Mar 2019 18:03:37 -0400 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Smatch warns about small size on two structs: drivers/media/platform/qcom/venus/hfi_parser.c:103 parse_profile_level() error: memcpy() 'proflevel' too small (8 vs 128) drivers/media/platform/qcom/venus/hfi_parser.c: drivers/media/platform/qcom/venus/hfi_parser.c:129 parse_caps() error: memcpy() 'cap' too small (16 vs 512) The reason is that the hfi_parser actually expects: - multiple data entries on hfi_capabilities - multiple profile_level on hfi_profile_level_supported However, the structs trick gcc, making it to believe that there's just one value for each. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/qcom/venus/hfi_helper.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/qcom/venus/hfi_helper.h b/drivers/media/platform/qcom/venus/hfi_helper.h index 15804ad7e65d..34ea503a9842 100644 --- a/drivers/media/platform/qcom/venus/hfi_helper.h +++ b/drivers/media/platform/qcom/venus/hfi_helper.h @@ -569,7 +569,7 @@ struct hfi_capability { struct hfi_capabilities { u32 num_capabilities; - struct hfi_capability data[1]; + struct hfi_capability *data; }; #define HFI_DEBUG_MSG_LOW 0x01 @@ -726,7 +726,7 @@ struct hfi_profile_level { struct hfi_profile_level_supported { u32 profile_count; - struct hfi_profile_level profile_level[1]; + struct hfi_profile_level *profile_level; }; struct hfi_quality_vs_speed {