[bug report] mtd: parsers: Add Qcom SMEM parser
Dan Carpenter
dan.carpenter at oracle.com
Fri Jan 8 07:52:41 EST 2021
Hello Manivannan Sadhasivam,
The patch 803eb124e1a6: "mtd: parsers: Add Qcom SMEM parser" from Jan
4, 2021, leads to the following static checker warning:
drivers/mtd/parsers/qcomsmempart.c:109 parse_qcomsmem_part()
warn: passing zero to 'PTR_ERR'
drivers/mtd/parsers/qcomsmempart.c
68 pr_debug("Parsing partition table info from SMEM\n");
69 ptable = qcom_smem_get(SMEM_APPS, SMEM_AARM_PARTITION_TABLE, &len);
70 if (IS_ERR(ptable)) {
Can "ptable" be NULL here?
71 pr_err("Error reading partition table header\n");
72 return PTR_ERR(ptable);
73 }
74
75 /* Verify ptable magic */
76 if (le32_to_cpu(ptable->magic1) != SMEM_FLASH_PART_MAGIC1 ||
77 le32_to_cpu(ptable->magic2) != SMEM_FLASH_PART_MAGIC2) {
78 pr_err("Partition table magic verification failed\n");
79 return -EINVAL;
80 }
81
82 /* Ensure that # of partitions is less than the max we have allocated */
83 numparts = le32_to_cpu(ptable->numparts);
84 if (numparts > SMEM_FLASH_PTABLE_MAX_PARTS_V4) {
85 pr_err("Partition numbers exceed the max limit\n");
86 return -EINVAL;
87 }
88
89 /* Find out length of partition data based on table version */
90 if (le32_to_cpu(ptable->version) <= SMEM_FLASH_PTABLE_V3) {
91 len = SMEM_FLASH_PTABLE_HDR_LEN + SMEM_FLASH_PTABLE_MAX_PARTS_V3 *
92 sizeof(struct smem_flash_pentry);
93 } else if (le32_to_cpu(ptable->version) == SMEM_FLASH_PTABLE_V4) {
94 len = SMEM_FLASH_PTABLE_HDR_LEN + SMEM_FLASH_PTABLE_MAX_PARTS_V4 *
95 sizeof(struct smem_flash_pentry);
96 } else {
97 pr_err("Unknown ptable version (%d)", le32_to_cpu(ptable->version));
98 return -EINVAL;
99 }
100
101 /*
102 * Now that the partition table header has been parsed, verified
103 * and the length of the partition table calculated, read the
104 * complete partition table
105 */
106 ptable = qcom_smem_get(SMEM_APPS, SMEM_AARM_PARTITION_TABLE, &len);
107 if (IS_ERR_OR_NULL(ptable)) {
108 pr_err("Error reading partition table\n");
109 return PTR_ERR(ptable);
If "ptable" is NULL then this code returns success. It's not clear if
that's intentional. If it is then just ignore this email. Thanks!
110 }
111
112 parts = kcalloc(numparts, sizeof(*parts), GFP_KERNEL);
regards,
dan carpenter
More information about the linux-mtd
mailing list