@@ -175,28 +175,17 @@ static enum fw_upload_err mpfs_auto_update_poll_complete(struct fw_upload *fw_up
175
175
static int mpfs_auto_update_verify_image (struct fw_upload * fw_uploader )
176
176
{
177
177
struct mpfs_auto_update_priv * priv = fw_uploader -> dd_handle ;
178
- struct mpfs_mss_response * response ;
179
- struct mpfs_mss_msg * message ;
180
- u32 * response_msg ;
178
+ u32 * response_msg __free (kfree ) =
179
+ kzalloc (AUTO_UPDATE_FEATURE_RESP_SIZE * sizeof (* response_msg ), GFP_KERNEL );
180
+ struct mpfs_mss_response * response __free (kfree ) =
181
+ kzalloc (sizeof (struct mpfs_mss_response ), GFP_KERNEL );
182
+ struct mpfs_mss_msg * message __free (kfree ) =
183
+ kzalloc (sizeof (struct mpfs_mss_msg ), GFP_KERNEL );
181
184
int ret ;
182
185
183
- response_msg = devm_kzalloc (priv -> dev , AUTO_UPDATE_FEATURE_RESP_SIZE * sizeof (* response_msg ),
184
- GFP_KERNEL );
185
- if (!response_msg )
186
+ if (!response_msg || !response || !message )
186
187
return - ENOMEM ;
187
188
188
- response = devm_kzalloc (priv -> dev , sizeof (struct mpfs_mss_response ), GFP_KERNEL );
189
- if (!response ) {
190
- ret = - ENOMEM ;
191
- goto free_response_msg ;
192
- }
193
-
194
- message = devm_kzalloc (priv -> dev , sizeof (struct mpfs_mss_msg ), GFP_KERNEL );
195
- if (!message ) {
196
- ret = - ENOMEM ;
197
- goto free_response ;
198
- }
199
-
200
189
/*
201
190
* The system controller can verify that an image in the flash is valid.
202
191
* Rather than duplicate the check in this driver, call the relevant
@@ -218,20 +207,12 @@ static int mpfs_auto_update_verify_image(struct fw_upload *fw_uploader)
218
207
ret = mpfs_blocking_transaction (priv -> sys_controller , message );
219
208
if (ret | response -> resp_status ) {
220
209
dev_warn (priv -> dev , "Verification of Upgrade Image failed!\n" );
221
- ret = ret ? ret : - EBADMSG ;
222
- goto free_message ;
210
+ return ret ? ret : - EBADMSG ;
223
211
}
224
212
225
213
dev_info (priv -> dev , "Verification of Upgrade Image passed!\n" );
226
214
227
- free_message :
228
- devm_kfree (priv -> dev , message );
229
- free_response :
230
- devm_kfree (priv -> dev , response );
231
- free_response_msg :
232
- devm_kfree (priv -> dev , response_msg );
233
-
234
- return ret ;
215
+ return 0 ;
235
216
}
236
217
237
218
static int mpfs_auto_update_set_image_address (struct mpfs_auto_update_priv * priv ,
@@ -406,23 +387,15 @@ static const struct fw_upload_ops mpfs_auto_update_ops = {
406
387
407
388
static int mpfs_auto_update_available (struct mpfs_auto_update_priv * priv )
408
389
{
409
- struct mpfs_mss_response * response ;
410
- struct mpfs_mss_msg * message ;
411
- u32 * response_msg ;
390
+ u32 * response_msg __free (kfree ) =
391
+ kzalloc (AUTO_UPDATE_FEATURE_RESP_SIZE * sizeof (* response_msg ), GFP_KERNEL );
392
+ struct mpfs_mss_response * response __free (kfree ) =
393
+ kzalloc (sizeof (struct mpfs_mss_response ), GFP_KERNEL );
394
+ struct mpfs_mss_msg * message __free (kfree ) =
395
+ kzalloc (sizeof (struct mpfs_mss_msg ), GFP_KERNEL );
412
396
int ret ;
413
397
414
- response_msg = devm_kzalloc (priv -> dev ,
415
- AUTO_UPDATE_FEATURE_RESP_SIZE * sizeof (* response_msg ),
416
- GFP_KERNEL );
417
- if (!response_msg )
418
- return - ENOMEM ;
419
-
420
- response = devm_kzalloc (priv -> dev , sizeof (struct mpfs_mss_response ), GFP_KERNEL );
421
- if (!response )
422
- return - ENOMEM ;
423
-
424
- message = devm_kzalloc (priv -> dev , sizeof (struct mpfs_mss_msg ), GFP_KERNEL );
425
- if (!message )
398
+ if (!response_msg || !response || !message )
426
399
return - ENOMEM ;
427
400
428
401
/*
0 commit comments