Re: [PATCH-v3 13/14] iscsi-target: Add misc utility and debug logic

From: Arne Redlich
Date: Fri May 13 2011 - 15:30:50 EST


2011/5/12 Nicholas A. Bellinger <nab@xxxxxxxxxxxxxxx>:
> From: Nicholas Bellinger <nab@xxxxxxxxxxxxxxx>
>
> This file adds iscsi_target_util.[c,h] code containing a number
> of miscellaneous utility functions for iscsi_target_mod.
>
> It also contains iscsi_debug.h macros for CONFIG_ISCSI_TARGET_DEBUG
>
> Signed-off-by: Nicholas A. Bellinger <nab@xxxxxxxxxxxxxxx>

<snip>

> diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c
> new file mode 100644
> index 0000000..af1c5c44
> --- /dev/null
> +++ b/drivers/target/iscsi/iscsi_target_util.c

<snip>

> +
> +struct iscsi_r2t *iscsit_get_r2t_for_eos(
> + Â Â Â struct iscsi_cmd *cmd,
> + Â Â Â u32 offset,
> + Â Â Â u32 length)
> +{
> + Â Â Â struct iscsi_r2t *r2t;
> +
> + Â Â Â spin_lock_bh(&cmd->r2t_lock);
> + Â Â Â list_for_each_entry(r2t, &cmd->cmd_r2t_list, r2t_list) {
> + Â Â Â Â Â Â Â if ((r2t->offset <= offset) &&
> + Â Â Â Â Â Â Â Â Â (r2t->offset + r2t->xfer_len) >= (offset + length))
> + Â Â Â Â Â Â Â Â Â Â Â break;
> + Â Â Â }
> + Â Â Â spin_unlock_bh(&cmd->r2t_lock);
> +
> + Â Â Â if (!r2t) {
> + Â Â Â Â Â Â Â printk(KERN_ERR "Unable to locate R2T for Offset: %u, Length:"
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â " %u\n", offset, length);
> + Â Â Â Â Â Â Â return NULL;
> + Â Â Â }
> +
> + Â Â Â return r2t;
> +}
> +

Nicholas,

This lookup pattern (repeated several times throughout the patch)
looks seriously flawed to me as r2t will never be NULL.

Arne
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/