From: kernel test robot <lkp@intel.com>
To: kbuild@lists.01.org
Subject: [linuxtv-media:master 191/214] drivers/media/i2c/ov2740.c:945 ov2740_load_otp_data() warn: variable dereferenced before check 'nvm' (see line 939)
Date: Fri, 27 Nov 2020 06:58:50 +0800 [thread overview]
Message-ID: <202011270645.Bta0Frv9-lkp@intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 7820 bytes --]
CC: kbuild-all(a)lists.01.org
CC: linux-media(a)vger.kernel.org
TO: Bingbu Cao <bingbu.cao@intel.com>
CC: Mauro Carvalho Chehab <mchehab@kernel.org>
CC: linux-media(a)vger.kernel.org
CC: Qingwu Zhang <qingwu.zhang@intel.com>
CC: Tomasz Figa <tfiga@chromium.org>
CC: Sakari Ailus <sakari.ailus@linux.intel.com>
tree: git://linuxtv.org/media_tree.git master
head: 711561a41d1f70ad939c3ff3cf00e75fa8238337
commit: 798f1a6b0efcb33e5f3abe048aa9d546ca849cd8 [191/214] media: ov2740: only do OTP data read on demand from user
:::::: branch date: 9 hours ago
:::::: commit date: 33 hours ago
config: parisc-randconfig-m031-20201127 (attached as .config)
compiler: hppa-linux-gcc (GCC) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch warnings:
drivers/media/i2c/ov2740.c:945 ov2740_load_otp_data() warn: variable dereferenced before check 'nvm' (see line 939)
vim +/nvm +945 drivers/media/i2c/ov2740.c
866edc895171f1 Bingbu Cao 2020-05-11 936
798f1a6b0efcb3 Bingbu Cao 2020-11-13 937 static int ov2740_load_otp_data(struct nvm_data *nvm)
7b981288285f0e Qingwu Zhang 2020-06-12 938 {
798f1a6b0efcb3 Bingbu Cao 2020-11-13 @939 struct i2c_client *client = nvm->client;
7b981288285f0e Qingwu Zhang 2020-06-12 940 struct ov2740 *ov2740 = to_ov2740(i2c_get_clientdata(client));
7b981288285f0e Qingwu Zhang 2020-06-12 941 u32 isp_ctrl00 = 0;
7b981288285f0e Qingwu Zhang 2020-06-12 942 u32 isp_ctrl01 = 0;
7b981288285f0e Qingwu Zhang 2020-06-12 943 int ret;
7b981288285f0e Qingwu Zhang 2020-06-12 944
798f1a6b0efcb3 Bingbu Cao 2020-11-13 @945 if (!nvm)
798f1a6b0efcb3 Bingbu Cao 2020-11-13 946 return -EINVAL;
798f1a6b0efcb3 Bingbu Cao 2020-11-13 947
798f1a6b0efcb3 Bingbu Cao 2020-11-13 948 if (nvm->nvm_buffer)
798f1a6b0efcb3 Bingbu Cao 2020-11-13 949 return 0;
798f1a6b0efcb3 Bingbu Cao 2020-11-13 950
798f1a6b0efcb3 Bingbu Cao 2020-11-13 951 nvm->nvm_buffer = kzalloc(CUSTOMER_USE_OTP_SIZE, GFP_KERNEL);
798f1a6b0efcb3 Bingbu Cao 2020-11-13 952 if (!nvm->nvm_buffer)
798f1a6b0efcb3 Bingbu Cao 2020-11-13 953 return -ENOMEM;
798f1a6b0efcb3 Bingbu Cao 2020-11-13 954
7b981288285f0e Qingwu Zhang 2020-06-12 955 ret = ov2740_read_reg(ov2740, OV2740_REG_ISP_CTRL00, 1, &isp_ctrl00);
7b981288285f0e Qingwu Zhang 2020-06-12 956 if (ret) {
7b981288285f0e Qingwu Zhang 2020-06-12 957 dev_err(&client->dev, "failed to read ISP CTRL00\n");
798f1a6b0efcb3 Bingbu Cao 2020-11-13 958 goto err;
7b981288285f0e Qingwu Zhang 2020-06-12 959 }
798f1a6b0efcb3 Bingbu Cao 2020-11-13 960
7b981288285f0e Qingwu Zhang 2020-06-12 961 ret = ov2740_read_reg(ov2740, OV2740_REG_ISP_CTRL01, 1, &isp_ctrl01);
7b981288285f0e Qingwu Zhang 2020-06-12 962 if (ret) {
7b981288285f0e Qingwu Zhang 2020-06-12 963 dev_err(&client->dev, "failed to read ISP CTRL01\n");
798f1a6b0efcb3 Bingbu Cao 2020-11-13 964 goto err;
7b981288285f0e Qingwu Zhang 2020-06-12 965 }
7b981288285f0e Qingwu Zhang 2020-06-12 966
7b981288285f0e Qingwu Zhang 2020-06-12 967 /* Clear bit 5 of ISP CTRL00 */
7b981288285f0e Qingwu Zhang 2020-06-12 968 ret = ov2740_write_reg(ov2740, OV2740_REG_ISP_CTRL00, 1,
7b981288285f0e Qingwu Zhang 2020-06-12 969 isp_ctrl00 & ~BIT(5));
7b981288285f0e Qingwu Zhang 2020-06-12 970 if (ret) {
798f1a6b0efcb3 Bingbu Cao 2020-11-13 971 dev_err(&client->dev, "failed to set ISP CTRL00\n");
798f1a6b0efcb3 Bingbu Cao 2020-11-13 972 goto err;
7b981288285f0e Qingwu Zhang 2020-06-12 973 }
7b981288285f0e Qingwu Zhang 2020-06-12 974
7b981288285f0e Qingwu Zhang 2020-06-12 975 /* Clear bit 7 of ISP CTRL01 */
7b981288285f0e Qingwu Zhang 2020-06-12 976 ret = ov2740_write_reg(ov2740, OV2740_REG_ISP_CTRL01, 1,
7b981288285f0e Qingwu Zhang 2020-06-12 977 isp_ctrl01 & ~BIT(7));
7b981288285f0e Qingwu Zhang 2020-06-12 978 if (ret) {
798f1a6b0efcb3 Bingbu Cao 2020-11-13 979 dev_err(&client->dev, "failed to set ISP CTRL01\n");
798f1a6b0efcb3 Bingbu Cao 2020-11-13 980 goto err;
7b981288285f0e Qingwu Zhang 2020-06-12 981 }
7b981288285f0e Qingwu Zhang 2020-06-12 982
7b981288285f0e Qingwu Zhang 2020-06-12 983 ret = ov2740_write_reg(ov2740, OV2740_REG_MODE_SELECT, 1,
7b981288285f0e Qingwu Zhang 2020-06-12 984 OV2740_MODE_STREAMING);
7b981288285f0e Qingwu Zhang 2020-06-12 985 if (ret) {
798f1a6b0efcb3 Bingbu Cao 2020-11-13 986 dev_err(&client->dev, "failed to set streaming mode\n");
798f1a6b0efcb3 Bingbu Cao 2020-11-13 987 goto err;
7b981288285f0e Qingwu Zhang 2020-06-12 988 }
7b981288285f0e Qingwu Zhang 2020-06-12 989
7b981288285f0e Qingwu Zhang 2020-06-12 990 /*
7b981288285f0e Qingwu Zhang 2020-06-12 991 * Users are not allowed to access OTP-related registers and memory
7b981288285f0e Qingwu Zhang 2020-06-12 992 * during the 20 ms period after streaming starts (0x100 = 0x01).
7b981288285f0e Qingwu Zhang 2020-06-12 993 */
7b981288285f0e Qingwu Zhang 2020-06-12 994 msleep(20);
7b981288285f0e Qingwu Zhang 2020-06-12 995
7b981288285f0e Qingwu Zhang 2020-06-12 996 ret = regmap_bulk_read(nvm->regmap, OV2740_REG_OTP_CUSTOMER,
7b981288285f0e Qingwu Zhang 2020-06-12 997 nvm->nvm_buffer, CUSTOMER_USE_OTP_SIZE);
7b981288285f0e Qingwu Zhang 2020-06-12 998 if (ret) {
7b981288285f0e Qingwu Zhang 2020-06-12 999 dev_err(&client->dev, "failed to read OTP data, ret %d\n", ret);
798f1a6b0efcb3 Bingbu Cao 2020-11-13 1000 goto err;
7b981288285f0e Qingwu Zhang 2020-06-12 1001 }
7b981288285f0e Qingwu Zhang 2020-06-12 1002
798f1a6b0efcb3 Bingbu Cao 2020-11-13 1003 ret = ov2740_write_reg(ov2740, OV2740_REG_MODE_SELECT, 1,
7b981288285f0e Qingwu Zhang 2020-06-12 1004 OV2740_MODE_STANDBY);
798f1a6b0efcb3 Bingbu Cao 2020-11-13 1005 if (ret) {
798f1a6b0efcb3 Bingbu Cao 2020-11-13 1006 dev_err(&client->dev, "failed to set streaming mode\n");
798f1a6b0efcb3 Bingbu Cao 2020-11-13 1007 goto err;
798f1a6b0efcb3 Bingbu Cao 2020-11-13 1008 }
798f1a6b0efcb3 Bingbu Cao 2020-11-13 1009
798f1a6b0efcb3 Bingbu Cao 2020-11-13 1010 ret = ov2740_write_reg(ov2740, OV2740_REG_ISP_CTRL01, 1, isp_ctrl01);
798f1a6b0efcb3 Bingbu Cao 2020-11-13 1011 if (ret) {
798f1a6b0efcb3 Bingbu Cao 2020-11-13 1012 dev_err(&client->dev, "failed to set ISP CTRL01\n");
798f1a6b0efcb3 Bingbu Cao 2020-11-13 1013 goto err;
798f1a6b0efcb3 Bingbu Cao 2020-11-13 1014 }
798f1a6b0efcb3 Bingbu Cao 2020-11-13 1015
798f1a6b0efcb3 Bingbu Cao 2020-11-13 1016 ret = ov2740_write_reg(ov2740, OV2740_REG_ISP_CTRL00, 1, isp_ctrl00);
798f1a6b0efcb3 Bingbu Cao 2020-11-13 1017 if (ret) {
798f1a6b0efcb3 Bingbu Cao 2020-11-13 1018 dev_err(&client->dev, "failed to set ISP CTRL00\n");
798f1a6b0efcb3 Bingbu Cao 2020-11-13 1019 goto err;
798f1a6b0efcb3 Bingbu Cao 2020-11-13 1020 }
798f1a6b0efcb3 Bingbu Cao 2020-11-13 1021
798f1a6b0efcb3 Bingbu Cao 2020-11-13 1022 return 0;
798f1a6b0efcb3 Bingbu Cao 2020-11-13 1023 err:
798f1a6b0efcb3 Bingbu Cao 2020-11-13 1024 kfree(nvm->nvm_buffer);
798f1a6b0efcb3 Bingbu Cao 2020-11-13 1025 nvm->nvm_buffer = NULL;
7b981288285f0e Qingwu Zhang 2020-06-12 1026
7b981288285f0e Qingwu Zhang 2020-06-12 1027 return ret;
7b981288285f0e Qingwu Zhang 2020-06-12 1028 }
7b981288285f0e Qingwu Zhang 2020-06-12 1029
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 38775 bytes --]
reply other threads:[~2020-11-26 22:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202011270645.Bta0Frv9-lkp@intel.com \
--to=lkp@intel.com \
--cc=kbuild@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.