Re: [PATCH with SmPL?] staging: rtl8188eu: Adjustments around jump labels

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>>>> @@ -212,8 +212,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16
>>>> _size_byte, u8  *pbuf)
>>>>  exit:
>>>>  	kfree(efuseTbl);
>>>>
>>>> -	if (eFuseWord)
>>>> -		kfree(eFuseWord);
>>>> +	kfree(eFuseWord);
>>>
>>> I think that this code has been updated already.  It would be better to
>>> add labels so that kfree is only executed when needed.
>>
>> Are there any chances to achieve the suggested fine-tuning for jump labels
>> also with another semantic patch approach?
> 
> No, I don't think so.  The pattern is not regular enough.

Now I have got a different impression for corresponding improvement possibilities.


elfring@Sonne:~/Projekte/Linux/stable-patched> spatch.opt -debug -sp-file ~/Projekte/Coccinelle/janitor/move_function_call_before_jump_label1.cocci drivers/staging/rtl8188eu/core/rtw_efuse.c
init_defs_builtins: /usr/local/share/coccinelle/standard.h
-----------------------------------------------------------------------
processing semantic patch file: /home/elfring/Projekte/Coccinelle/janitor/move_function_call_before_jump_label1.cocci
with isos from: /usr/local/share/coccinelle/standard.iso
-----------------------------------------------------------------------
@move_function_call_before_jump_label@
expression x;
identifier fu, label;
type t;
@@
 t fu(...)
 {
  ... when any
  x = kzalloc(...);
  if (x == NULL) {
     ...
     goto label;
  }
  ... when any
+    kfree(x);
  label:
-    kfree(x);
  ...
 }

HANDLING: drivers/staging/rtl8188eu/core/rtw_efuse.c
-----------------------------------------------------------------------
let's go
-----------------------------------------------------------------------
-----------------------------------------------------------------------
-----------------------------------------------------------------------
move_function_call_before_jump_label = 
-----------------------------------------------------------------------
dependencies for rule move_function_call_before_jump_label satisfied:
binding in = []
binding relevant in = []
     (ONCE) USING optional_storage builtin isomorphism
     transformation info returned:
          transform state: 5
               with rule_elem: 
                                 <<< kfree(move_function_call_before_jump_label:x);
                               move_function_call_before_jump_label:label:
               with binding: [move_function_call_before_jump_label.x --> efuseTbl]
          transform state: 204
               with rule_elem: -kfree-(-move_function_call_before_jump_label:x-)-;
               with binding: [move_function_call_before_jump_label.x --> efuseTbl]
     binding out = []
     transform one node: 204
     transform one node: 5
-----------------------------------------------------------------------
Finished
-----------------------------------------------------------------------
diff = 
--- drivers/staging/rtl8188eu/core/rtw_efuse.c
+++ /tmp/cocci-output-4498-349827-rtw_efuse.c
@@ -209,8 +209,8 @@ efuse_phymap_to_logical(u8 *phymap, u16
        /*  5. Calculate Efuse utilization. */
        /*  */
 
+kfree(efuseTbl);
 exit:
-       kfree(efuseTbl);
 
        kfree(eFuseWord);
 }
Check duplication for 1 files



Can my update suggestion be generalised a bit more for the movement of specific jump labels
towards the end of a function implementation like in the use case "efuse_phymap_to_logical()"?

Regards,
Markus
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux