lkml.org 
[lkml]   [2013]   [Jan]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 8/9] dasd: Add 'timeout' attribute
From
Date
Hannes Reinecke <hare@suse.de> wrote on 2013-01-29 08:12:00:
[..]
> +static ssize_t
> +dasd_timeout_store(struct device *dev, struct device_attribute *attr,
> + const char *buf, size_t count)
> +{
> + struct dasd_device *device;
> + struct request_queue *q;
> + unsigned long val, flags;
> +
> + device = dasd_device_from_cdev(to_ccwdev(dev));
> + if (IS_ERR(device))
> + return -ENODEV;
> +
> + if ((strict_strtoul(buf, 10, &val) != 0) ||
> + val > ULONG_MAX / HZ) {
> + dasd_put_device(device);
> + return -EINVAL;
> + }
> + q = device->block->request_queue;

You need to check device->block before using it.
For alias devices the device->block pointer is NULL, as an alias device
has no fixed association with a block device.

> + if (!q) {
> + dasd_put_device(device);
> + return -ENODEV;
> + }
> + spin_lock_irqsave(&device->block->request_queue_lock, flags);
> + if (!val)
> + blk_queue_rq_timed_out(q, NULL);
> + else
> + blk_queue_rq_timed_out(q, dasd_times_out);
> +
> + device->blk_timeout = val;
> +
> + blk_queue_rq_timeout(q, device->blk_timeout * HZ);
> + spin_unlock_irqrestore(&device->block->request_queue_lock, flags);
> +
> + dasd_put_device(device);
> + return count;
> +}
> +
[..]

Mit freundlichen Grüßen / Kind regards

Stefan Weinhuber

--
Linux for zSeries kernel development
IBM Systems &Technology Group, Systems Software Development / SW Linux für
zSeries Entwicklung

IBM Deutschland
Schoenaicher Str. 220
71032 Boeblingen
Phone: +49-7031-16-4018
E-Mail: wein@de.ibm.com

IBM Deutschland Research & Development GmbH / Vorsitzender des
Aufsichtsrats: Martina Koederitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart,
HRB 243294

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

\
 
 \ /
  Last update: 2013-01-29 17:02    [W:0.115 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site