On Sat, 10 Jul 2010 19:21:22 +1000 Mark Harvey <markh794@xxxxxxxxx> wrote: > FUJITA Tomonori wrote: > > On Thu, 8 Jul 2010 11:44:05 +1000 > > Mark Harvey <markh794@xxxxxxxxx> wrote: > > > > > >> This was one way to resolve the segfault if .cmd_passthrough() is NULL > >> > >> > >> From cd9c358476090d1a1758aba03157c30e60c53e57 Mon Sep 17 00:00:00 2001 > >> From: Mark Harvey <markh794@xxxxxxxxx> > >> Date: Thu, 8 Jul 2010 06:48:02 +1000 > >> Subject: Prevent segfault if passthrough params not correct. > >> > >> If user neglects to supply '--device_type=pt' when creating a > >> passthrough device, tgtd would segfault due to .cmd_passthrough() being NULL > >> > >> Signed-off-by: Mark Harvey <markh794@xxxxxxxxx> > >> --- > >> usr/bs_sg.c | 8 ++++++++ > >> usr/mmc.c | 1 + > >> usr/osd.c | 1 + > >> usr/sbc.c | 1 + > >> usr/scc.c | 6 ++++++ > >> usr/smc.c | 1 + > >> usr/ssc.c | 2 +- > >> usr/tgtd.h | 1 + > >> 8 files changed, 20 insertions(+), 1 deletions(-) > >> > > > > Better to check this earlier (that is, when we create a new device)? > > > > How about something like this (not tested)? > > > > = > > From: FUJITA Tomonori <fujita.tomonori@xxxxxxxxxxxxx> > > Subject: [PATCH] check pt device creation > > > > Signed-off-by: FUJITA Tomonori <fujita.tomonori@xxxxxxxxxxxxx> > > --- > > usr/target.c | 7 +++++++ > > 1 files changed, 7 insertions(+), 0 deletions(-) > > > > diff --git a/usr/target.c b/usr/target.c > > index 5fbfb0e..bb5b0c8 100644 > > --- a/usr/target.c > > +++ b/usr/target.c > > @@ -490,6 +490,13 @@ int tgt_device_create(int tid, int dev_type, uint64_t lun, char *params, > > } else > > bst = get_backingstore_template("null"); > > > > + if ((!strncmp(bst->bs_name, "bsg", 3) || > > + !strncmp(bst->bs_name, "sg", 2)) && > > + dev_type != TYPE_PT) { > > + ret = TGTADM_INVALID_REQUEST; > > + goto out; > > + } > > + > > lu_bsoflags = str_to_open_flags(bsoflags); > > if (lu_bsoflags == -1) { > > ret = TGTADM_INVALID_REQUEST; > > > > Tested & confirmed this patch works for me as well. Applied, thanks a lot! -- To unsubscribe from this list: send the line "unsubscribe stgt" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html