From: Dan Carpenter <dan.carpenter@oracle.com>
To: csharper2005@gmail.com
Cc: linux-mtd@lists.infradead.org
Subject: [bug report] mtd: parsers: add support for Sercomm partitions
Date: Wed, 18 May 2022 20:33:01 +0300 [thread overview]
Message-ID: <YoUtzUMdJOihZv2L@kili> (raw)
Hello Mikhail Zhilkin,
The patch 4213e556fe2a: "mtd: parsers: add support for Sercomm
partitions" from May 3, 2022, leads to the following Smatch static
checker warning:
drivers/mtd/parsers/scpart.c:155 scpart_parse()
warn: missing error code here? 'mtd_get_of_node()' failed. 'res' = '0'
drivers/mtd/parsers/scpart.c
138 static int scpart_parse(struct mtd_info *master,
139 const struct mtd_partition **pparts,
140 struct mtd_part_parser_data *data)
141 {
142 struct sc_part_desc *scpart_map = NULL;
143 struct mtd_partition *parts = NULL;
144 struct device_node *mtd_node;
145 struct device_node *ofpart_node;
146 struct device_node *pp;
147 const char *partname;
148 int nr_scparts;
149 int nr_parts = 0;
150 int n;
151 int res = 0;
152
153 mtd_node = mtd_get_of_node(master);
154 if (!mtd_node)
--> 155 goto out;
^^^^^^^^
156
157 ofpart_node = of_get_child_by_name(mtd_node, "partitions");
158 if (!ofpart_node)
159 goto out;
^^^^^^^^
Are these supposed to be success paths?
160
161 nr_scparts = scpart_find_partmap(master, &scpart_map);
162 if (nr_scparts <= 0) {
Is nr_scparts == 0 a success path?
163 res = nr_scparts;
164 goto free;
165 }
166
167 parts = kcalloc(of_get_child_count(ofpart_node), sizeof(*parts),
168 GFP_KERNEL);
169 if (!parts) {
170 res = -ENOMEM;
171 goto out;
172 }
173
174 for_each_child_of_node(ofpart_node, pp) {
175 u32 scpart_id;
176
177 if (of_property_read_u32(pp, "sercomm,scpart-id", &scpart_id))
178 continue;
179
180 for (n = 0 ; n < nr_scparts ; n++)
181 if ((scpart_map[n].part_id != ID_ALREADY_FOUND) &&
182 (scpart_id == scpart_map[n].part_id))
183 break;
184 if (n >= nr_scparts)
185 /* not match */
186 continue;
187
188 /* add the partition found in OF into MTD partition array */
189 parts[nr_parts].offset = scpart_map[n].part_offs;
190 parts[nr_parts].size = scpart_map[n].part_bytes;
191 parts[nr_parts].of_node = pp;
192
193 if (!of_property_read_string(pp, "label", &partname))
194 parts[nr_parts].name = partname;
195 if (of_property_read_bool(pp, "read-only"))
196 parts[nr_parts].mask_flags |= MTD_WRITEABLE;
197 if (of_property_read_bool(pp, "lock"))
198 parts[nr_parts].mask_flags |= MTD_POWERUP_LOCK;
199
200 /* mark as 'done' */
201 scpart_map[n].part_id = ID_ALREADY_FOUND;
202
203 nr_parts++;
204 }
205
206 if (nr_parts > 0) {
207 *pparts = parts;
208 res = nr_parts;
209 } else
210 pr_info("No partition in OF matches partition ID with 'SC PART MAP'.\n");
211
212 of_node_put(pp);
213
214 free:
215 kfree(scpart_map);
216 if (res <= 0)
217 kfree(parts);
218
219 out:
220 return res;
221 }
regards,
dan carpenter
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next reply other threads:[~2022-05-18 17:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-18 17:33 Dan Carpenter [this message]
2022-05-28 10:49 ` [bug report] mtd: parsers: add support for Sercomm partitions Mikhail Zhilkin
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=YoUtzUMdJOihZv2L@kili \
--to=dan.carpenter@oracle.com \
--cc=csharper2005@gmail.com \
--cc=linux-mtd@lists.infradead.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.