From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756278AbcLRUoj (ORCPT ); Sun, 18 Dec 2016 15:44:39 -0500 Received: from mail-wj0-f194.google.com ([209.85.210.194]:35814 "EHLO mail-wj0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753817AbcLRUog (ORCPT ); Sun, 18 Dec 2016 15:44:36 -0500 From: Nicolas Iooss Subject: Uninitialized variable in bfad_im_bsg_els_ct_request To: Anil Gurumurthy , Sudarsana Kalluru , "James E.J. Bottomley" , "Martin K. Petersen" , Johannes Thumshirn Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Message-ID: Date: Sun, 18 Dec 2016 21:44:33 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Currently on Linus master tree and in linux-next [1], bfad_im_bsg_els_ct_request() code starts with the following code: int bfad_im_bsg_els_ct_request(struct bsg_job *job) { /*...*/ struct fc_bsg_request *bsg_request = bsg_request; struct fc_bsg_reply *bsg_reply = job->reply; uint32_t command_type = bsg_request->msgcode; The local variable "bsg_request" is initialized to itself (which would usually mean it is uninitialized) but it is dereferenced in order to get its "msgcode" field. As I am quite new to the kernel code and dereferencing self-initialized local variables looks black magic to me, could you please describe why this code is valid? It has recently been introduced by commit 01e0e15c8b3b ("scsi: don't use fc_bsg_job::request and fc_bsg_job::reply directly"). Thanks, Nicolas Iooss [1] https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/scsi/bfa/bfad_bsg.c?id=06548160dfecd1983ffd9d6795242a5cda095da5#n3356