On Mon, May 03, 2010 at 05:50:43PM -0400, Bill Pemberton wrote:
> kfree() knows how to deal with NULL, so there's no reason to check for
> NULL before passing something to it.
>
> Signed-off-by: Bill Pemberton <[email protected]>
> ---
> drivers/staging/hv/ChannelMgmt.c | 6 ++----
> drivers/staging/hv/Hv.c | 10 +++++-----
> 2 files changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/staging/hv/ChannelMgmt.c
> b/drivers/staging/hv/ChannelMgmt.c
> index 43f28f2..8d5f305 100644
> --- a/drivers/staging/hv/ChannelMgmt.c
> +++ b/drivers/staging/hv/ChannelMgmt.c
> @@ -642,10 +642,8 @@ int VmbusChannelRequestOffers(void)
>
>
> Cleanup:
> - if (msgInfo) {
> - kfree(msgInfo->WaitEvent);
> - kfree(msgInfo);
> - }
> + kfree(msgInfo->WaitEvent);
If msgInfo was NULL, you just oopsed here :(
> + kfree(msgInfo);
This is ok to pass NULL to.
>
> DPRINT_EXIT(VMBUS);
> return ret;
> diff --git a/drivers/staging/hv/Hv.c b/drivers/staging/hv/Hv.c
> index 62debf8..2e2222d 100644
> --- a/drivers/staging/hv/Hv.c
> +++ b/drivers/staging/hv/Hv.c
> @@ -305,11 +305,11 @@ void HvCleanup(void)
>
> DPRINT_ENTER(VMBUS);
>
> - if (gHvContext.SignalEventBuffer) {
> - kfree(gHvContext.SignalEventBuffer);
> - gHvContext.SignalEventBuffer = NULL;
> - gHvContext.SignalEventParam = NULL;
> - }
> +
> + kfree(gHvContext.SignalEventBuffer);
> + gHvContext.SignalEventBuffer = NULL;
> + gHvContext.SignalEventParam = NULL;
Is it "safe" to set gHvContext.SignalEventParam to NULL, even if
gHvContext.SignalEventBuffer was NULL to start with?
thanks,
greg k-h
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel