From ecb27e74441f2ee78f388a4e3e324aea1cff5bc7 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Thu, 29 May 2008 17:24:18 +0000 Subject: [PATCH] Patch from Bart Van Assche : The patch below fixes the checkpatch complaints on kfree(): WARNING: kfree(NULL) is safe this check is probabally not required This patch has been verified as follows: - Verified that checkpatch does no longer complain about kfree(). - Verified that make -s clean && make -s iscsi scst && make -s -C srpt still works and does not trigger any new compiler warnings. - Checked that the patch generated by generate-kernel-patch still applies cleanly to the 2.6.25.4 kernel, and that the patched kernel tree still compiles, installs and boots fine, and that the iscsi-scst, ib_srpt, scst_disk and scst_vdisk modules still load. Note: I'm not sure any of the above verifications did trigger the code paths changed by this patch. Signed-off-by: Bart Van Assche git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@402 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- mpt/mpt_scst.c | 3 +-- scst/src/dev_handlers/scst_vdisk.c | 12 ++++-------- scst/src/scst_main.c | 6 ++---- srpt/src/ib_srpt.c | 8 +++----- 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/mpt/mpt_scst.c b/mpt/mpt_scst.c index 73f82be02..c0f03aca1 100644 --- a/mpt/mpt_scst.c +++ b/mpt/mpt_scst.c @@ -4592,8 +4592,7 @@ mpt_stm_adapter_install(MPT_ADAPTER *ioc) if (priv == NULL) { printk(KERN_ERR MYNAM ":%s failed to allocate private structure\n", ioc->name); - if (priv != NULL) - kfree(priv); + kfree(priv); return (-1); } memset(priv, 0, sizeof(*priv)); diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 9463ab84b..b228dad8c 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -548,8 +548,7 @@ static void vdisk_free_thr_data(struct scst_thr_data_hdr *d) if (thr->fd) filp_close(thr->fd, NULL); - if (thr->iv != NULL) - kfree(thr->iv); + kfree(thr->iv); kmem_cache_free(vdisk_thr_cachep, thr); @@ -1926,8 +1925,7 @@ static struct iovec *vdisk_alloc_iv(struct scst_cmd *cmd, iv_count = scst_get_buf_count(cmd); if (iv_count > thr->iv_count) { - if (thr->iv != NULL) - kfree(thr->iv); + kfree(thr->iv); thr->iv = kmalloc(sizeof(*thr->iv) * iv_count, GFP_KERNEL); if (thr->iv == NULL) { PRINT_ERROR("Unable to allocate iv (%d)", iv_count); @@ -3011,8 +3009,7 @@ static int vcdrom_close(char *name) list_del(&virt_dev->vdisk_dev_list_entry); - if (virt_dev->file_name) - kfree(virt_dev->file_name); + kfree(virt_dev->file_name); kfree(virt_dev); out: @@ -3148,8 +3145,7 @@ static int vcdrom_change(char *p, char *name) virt_dev->name); } - if (old_fn) - kfree(old_fn); + kfree(old_fn); out_resume: scst_resume_activity(); diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index c286860fe..f42eacd58 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -352,8 +352,7 @@ out: return tgt; out_free_name: - if (tgt->default_group_name) - kfree(tgt->default_group_name); + kfree(tgt->default_group_name); out_free_err: mutex_unlock(&scst_mutex); @@ -406,8 +405,7 @@ void scst_unregister(struct scst_tgt *tgt) scst_cleanup_proc_target_entries(tgt); - if (tgt->default_group_name) - kfree(tgt->default_group_name); + kfree(tgt->default_group_name); mutex_unlock(&scst_mutex); scst_resume_activity(); diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 925baaf6d..a4a2a3bf9 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -614,14 +614,12 @@ static void srpt_reset_ioctx(struct srpt_rdma_ch *ch, struct srpt_ioctx *ioctx) if (ioctx->n_rdma_ius > 0 && ioctx->rdma_ius) { struct rdma_iu *riu = ioctx->rdma_ius; - for (i = 0; i < ioctx->n_rdma_ius; ++i, ++riu) { - if (riu->sge) - kfree(riu->sge); - } + for (i = 0; i < ioctx->n_rdma_ius; ++i, ++riu) + kfree(riu->sge); kfree(ioctx->rdma_ius); } - if (ioctx->n_rbuf > 1 && ioctx->rbufs) + if (ioctx->n_rbuf > 1) kfree(ioctx->rbufs); if (srpt_post_recv(ch->sport->sdev, ioctx))